One of the Most Useful Git Features
Contents
A while ago a colleague introduced me to a shortcut in git that improved my productivity tremendously: the - placeholder.
If you use a Unix-like operating system you already know how useful - is — it represents stdin/stdout in pipelines, or the previous directory in the shell. The cd - trick is also available in git: - refers to the previously checked-out branch.
There are plenty of situations where I need to quickly switch to a branch and then back. Previously I had to remember and retype the branch name. With - I can just run:
|
|
This not only saves typing but is also useful for writing scripts that are agnostic to the current branch.