Git quick-start basics

Hi there you are reading my Git notes for a basic quickstart Git demo flow, I intend to cleanup in the future but in the meantime feel free to look-around and let me know if you have any doubts.

Git starts with the branch “Master” by default (when you create a new repository)

Git has 3 states:

  1. Working directory (local folder)
  2. Staging (Git index) temporary space
  3. Commit (.git folder) repository, changes history

You can add a 4 state the “Remote”

Windows install


Mac (already installed in latest Mac), probably best to install Xcode first

  •  git version
    git version 2.15.2 (Apple Git-101.1)


Ok… so lets get started:

  • Login to GitHub and create a new repository
  • Get the HTTS address to clone it i.e.


  • $ cd github-demo/
  • $ ls
  • $ cat
    # github-demo
    Another simple demo repository to show the basic Git workflow
  • $ git status
    On branch master
    Your branch is up to date with ‘origin/master’.
    nothing to commit, working tree clean

Origin (Git automatically sets a relationship with GitHub and says it’s up to date)
It also says that our working directory is clean

  • $ echo “Just a dummy file to demo Git’s file tracking” >> start.txt
  • $ git status
    On branch master
    Your branch is up to date with ‘origin/master’.
    Untracked files:
      (use “git add <file>…” to include in what will be committed)
    nothing added to commit but untracked files present (use “git add” to track)

Git complains the added file is untracked
Lets add it to staging area:

  • $ git add start.txt
  • $ git status
    On branch master
    Your branch is up to date with ‘origin/master’.
    Changes to be committed:
      (use “git reset HEAD <file>…” to unstage)
    new file:   start.txt

Now the file is waiting to be commited (no changes into the repository {history of commits})
Saging area is designed so you can make changes without affecting the Commits history and can be added as a single atomic unique (all changes at once to a commit)

Ok lets commit it to local repository using git commit -m (m stands for message)

git commit -help

usage: git commit [<options>] [–] <pathspec>…

  •     -q, –quiet           suppress summary after successful commit
  •     -v, –verbose         show diff in commit message template

Commit message options

  •     -F, –file <file>     read message from file
  •     –author <author>     override author for commit
  •     –date <date>         override date for commit
  •     -m, –message <message>
  •                           commit message
  •     -c, –reedit-message <commit>
  •                           reuse and edit message from specified commit
  •     -C, –reuse-message <commit>
  •                           reuse message from specified commit
  •     –fixup <commit>      use autosquash formatted message to fixup specified commit
  •     –squash <commit>     use autosquash formatted message to squash specified commit
  •     –reset-author        the commit is authored by me now (used with -C/-c/–amend)
  •     -s, –signoff         add Signed-off-by:
  •     -t, –template <file>
  •                           use specified template file
  •     -e, –edit            force edit of commit
  •     –cleanup <default>   how to strip spaces and #comments from message
  •     –status              include status in commit message template
  •     -S, –gpg-sign[=<key-id>]
  •                           GPG sign commit

Commit contents options

  •     -a, –all             commit all changed files
  •     -i, –include         add specified files to index for commit
  •     –interactive         interactively add files
  •     -p, –patch           interactively add changes
  •     -o, –only            commit only specified files
  •     -n, –no-verify       bypass pre-commit and commit-msg hooks
  •     –dry-run             show what would be committed
  •     –short               show status concisely
  •     –branch              show branch information
  •     –porcelain           machine-readable output
  •     –long                show status in long format (default)
  •     -z, –null            terminate entries with NUL
  •     –amend               amend previous commit
  •     –no-post-rewrite     bypass post-rewrite hook
  •     -u, –untracked-files[=<mode>]
                              show untracked files, optional modes: all, normal, no. (Default: all)

git commit -m “Adding start.txt to demo our first commit”

  • [master 588d417] Adding start.txt to demo our first commit
    1 file changed, 1 insertion(+)
    create mode 100644 start.txt
    dhcp-10-159-135-46:github-demo jos$ git status
    On branch master
  • Your branch is ahead of ‘origin/master’ by 1 commit.
      (use “git push” to publish your local commits)
    nothing to commit, working tree clean

So now the changes (in this case just one file):

  • Has been moved from stage to the repository
  • We are notified that our local branch is ahead of origin/master by 1 commit
  • Our working tree is clean

Now let’s sync or local and remote repository with the push command:

  • git push origin master
    • origin : destination repository (in this case
      automatically configured when we used git clone command
    • master : destination branch
      as we mention at the begining, Git initializes the repository with just one branch named master


  • $git push origin master
    Counting objects: 3, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 342 bytes | 342.00 KiB/s, done.
    Total 3 (delta 0), reused 0 (delta 0)
       504c785..588d417  master -> master

With this we complete the basics of a Git flow

Bonus, configuring textmate2 as default editor:

  • Install textmate2 (Mac)
    • Open preferences and install shell support
  • Now integrate it with Git:
    • $git config –global core.editor “mate -w”
    • $ git config –global -e
      This should open textmate
Categories: Git

Leave a Reply