Pregunta

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.

¿Fue útil?

Solución

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 -

Otros consejos

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}".
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top