Contents

One of the most useful Git features

Contents

A while a go a colleague introduced me to this shortcut in git that improved my productivity tremendously. It was the power of -. If you use a Unix like operating systems you know how useful the - as place holder is e.g., representing the std-in/-out in command lines or the previous directory we have been in the shell. This last feature is also available in git with the difference that - can refer to the previous checkout branch.

There plenty of situations in which I quickly need to switch to a branch and then back. Previously I had to manually (remember and) retype the branch I came from. With the power of - I can just use git co - to switch back to previously checked out branch. This not only saves a lot of typing but is also useful for writing scripts that are agnostic to the current branch.