git checkout and see

Gabe Berke-Williams

If you use git, you’re running git checkout $BRANCH all the time. Everyone likes a fast checkout at the grocery store. How about making your git checkouts fast, too? Since I do it so often, I want it to go as fast as possible, and I bet you do too.

Are you … hot blooded?!

git checkout - (that’s git checkout followed by a dash) is the bee’s knees. It switches back to the branch you were on previously. If you run it again, you’re toggled back to the first branch. A useful comparison is cd -, which as you may know takes you back to your most recent directory. Here’s an example:

$ git branch
  alternate
* master
$ git checkout alternate
$ git branch
* alternate
  master
$ git checkout -
# Now we're back to master!
$ git branch
  alternate
* master

What are your favorite git tips and tricks?