For those familiar with the bash shell, you may know that it has the ability to change directory to the last directory you were in by using the cd -
command.
1 2 3 4 5 6 7 8 9 | $ cd /var/log/ $ cd /usr/local/bin $ pwd /usr/local/bin $ cd - /var/log $ cd - /usr/local/bin $ |
Lo and behold, Git has a similar feature as well, git checkout -
. This command will take you back to the last branch/tag/commit you had checked out
1 2 3 4 5 6 7 8 9 10 11 12 | $ git status On branch some_very_long_branch_name nothing to commit, working directory clean $ git checkout master Switched to branch 'master' Your branch is up-to- date with 'origin/master' . $ git fetch $ git pull Already up-to- date . $ git checkout - Switched to branch 'some_very_long_branch_name' $ |
–Proctor