Reputation: 25296
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.
Upvotes: 3
Views: 116
Reputation: 1954
I never would have found this without the answer from @KlasMellbourn, but this is actually mentioned in the git-checkout(1) man page (in the portion describing <branch>
):
As a special case, the "@{-N}" syntax for the N-th last branch checks out the
branch (instead of detaching). You may also specify - which is synonymous with
"@{-1}".
Upvotes: 1
Reputation: 44437
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 -
Upvotes: 3