Quick Switch Between Git Branches
Today’s little-known git feature (or maybe everyone knows but me? I only found this a few months ago) is for quickly switching between branches. Usually I would switch branches with:
git checkout [branchname]
However if you switch from one branch to another and want to switch back again (this happens when I’m reviewing changes and wondering if a bug is present on master as well), then you can do so by just doing:
git checkout -
Just a little timesaver in case it’s useful to anyone else – I know I’ve been using it quite a bit!
nice tip! I’ve been using git for years and I didn’t know that one
Pingback: Quick Switch Between Git Branches | Advanced PH...
Thanks for sharing, Lorna!
This is also true for `cd`. You can use `cd -` to move to whatever was your previous directory and the same again to return back.
This is great. Thanks for sharing. My team has decided to use painfully verbose and meaningful branch names.
This will be easy for me to remember too; it’s just like “fg -” in bash job control.