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.

有帮助吗?

解决方案

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 -

其他提示

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}".
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top