git checkout and see

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?

Goal-Oriented Git book cover

Goal-Oriented Git is our practical, no-nonsense guide to using Git to achieve your goals in everyday situations. If you've ever wanted to improve your Git skills without getting distracted by complex internals, then this book is for you.