And `git checkout -` to checkout the previously checked-out branch.
Wow. Thanks for this. I always cursed myself for forgetting to pushd, and now it turns out I didn't need to!
I recently found out that zsh lets you magically popd as well, as long as you're cding deeper into the tree. If you jump to a different subtree it will pop its internal stack until it finds a parent of the target dir.