git checkout -

Switch back to the previously checked-out branch

This command provides a quick way to return to the branch you were on before your current checkout.

It leverages Git's internal reference @- (also accessible via @{-1}) to identify the last-checked-out branch, allowing you to toggle between two branches without typing their full names.

Alternatives and complements include using git checkout @{-1} explicitly or the newer git switch - alias, as well as classic commands like git checkout <branch> for specific branch switches or git checkout -b <new> to create and switch in one step.

Related commands

Welcome to GitExamples!

Sign in to enable bookmarking, reminders, progress-tracking and more...