I’m embarrassed to have only found out about this cool gimmick. Using the command line, when you cd
to a given path, you can always revert to the previous path using cd -
, saving precious time in retyping it.
In Git, there’s the exact same use case: switching between branch with longer names can be exhausting for any lazy-typing developer and sometimes you just need to go back, nothing fancier. My motto is “think more, type less”, so I now use (you’ve guessed it) git checkout -
to switch to the previous branch. A few microseconds a day stack up!
So remember: git checkout —
to switch to the previous branch.