Git - go back to previous revision
I've found being able to go to the previous working directory in shell extremely useful - this can be achieved by doing
cd -
Which is effectively the same as
cd $OLDPWD
Today, I figured: it would be great if I could do the same with Git when it comes to changing between revisions. I decided to try it (you can see the current branch in parentheses) :
timur@timur: test (master) $ git branch
feature-x
* master
timur@timur: test (master) $ git checkout feature-x
Switched to branch 'feature-x'
timur@timur: test (feature-x) $ git checkout -
Switched to branch 'master'
timur@timur: test (master) $ git checkout -
Switched to branch 'feature-x'
timur@timur: test (feature-x) $
And it worked, just as expected, allowing you to switch between two branches very quickly.
UPDATE The "-" shortcut seems to work for merge just as well, so there might be more to this.
Written by Timur Strekalov
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Git
Authors
Related Tags
#git
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#