Search code examples
gitgit-checkoutgit-reflog

git checkout PREV


Is there a simple way to switch back to the branch you were most recently on prior to the current one? The same concept as "cd -" from the command line.

When working on multiple branches, this can be useful.


Solution

  • Just do:

    git checkout -
    

    Note the dash. This checks out the latest branch you were on before the current one.

    As you can see, the syntax is analogous to cd -