Last Updated: February 25, 2016
·
373
· bfontaine

Quickly switch between Git branches

With Bash, it's possible to quickly switch between two paths using the cd - command, e.g.:

~/foo $ cd ../bar
~/bar $ cd -
~/foo $ cd -
~/bar $

The git checkout command works the same:

$ git co master        # checkout master
$ git co -b foo_branch # checkout foo_branch
$ git co -             # checkout master again
$ git co -             # checkout foo_branch again
$