Phil for Humanity Phil for Humanity
A Guide for the Survival of Humankind and Helping the World, Society, and Yourself.

Git Checkout Enhancement

If you are a Git power user, then you are often switching between two branches. Wouldn’t it be convenient for a single command to go back to the previous Git branch that we were on previously?

Well, now you can. I created a simple wrapper script, called, that basically runs "git checkout". If you use the "-old" argument, then the command will change your branch to the previous branch. Otherwise, all other arguments are passed to "git checkout".

Here is the usage:

USAGE: <argument1> <argument2> <argument3> <argument4>
       This will run "git checkout .." with all passed in arguments
       while saving the previous branch name.

USAGE: -old
       This will run "git checkout <previously saved branch>".

You can download this Perl script here, or you can copy-n-paste from down below.

by Phil for Humanity
on 20131113

Related Articles
 » Git Error when Creating a Branch
 » Git Branches
 » Git Tag