First contact with Git

Because my shell history will not remember all those commands forever I dump some of my favorites here. Over time I surely will add more...

Git reset

git reset the index and working tree. Any changes to tracked files in the working tree since are discarded.

$ git reset --hard HEAD

Or revert latest local commit:

$ git reset HEAD~1

Git tag

Make an unsigned, annotated git tag object, delete and list tag objects.

$ git tag -a -m "Release 0.1.8" release_0_1_8
$ git tag -a -m "Release 0.1.8" v0.1.8
$ git tag -d release_0_1_8
$ git tag -l

git remote

How to show the currently used git remote:

$ git remote
$ git remote -v
origin  git:// (fetch)
origin  git:// (push)

git clone

Clone/checkout a single branch:

$ git clone -b docs --single-branch git://

git fetch

Fetch it like SourceTree:

  • Fetch from all remotes
  • Prune tracking branches no longer present on remote(s)
$ git fetch --all --prune

Also discussed on Stack Overflow: * How to fetch all git branches * How to prune local tracking branches that do not exist on remote anymore

Git submodule

Working with Git submodules...

The following sequence shows how to create (and checkout) all submodules recursively with foreach:

$ git submodule foreach git branch 3.7.0.M02
$ git submodule foreach git checkout 3.7.0.M02

Update Git submodule to latest commit on origin

$ git submodule update --remote --merge

Git bisect

To be continued...