Ad space (banner)
🌿Git Lessons
Lesson 52 / 59

Returning to Your Previous Branch with git switch -

This lesson covers quickly returning to your previous branch with git switch -. It's for anyone searching "git switch - usage."

git switch - is a shortcut for quickly returning to the branch you were on one step ago. Handy when you want to briefly check another branch, then jump right back to what you were doing.

In Try It, run git switch -. Just specifying a hyphen - takes you straight back to the previous branch, even if you don't remember its name.

A common early mistake is typing out the branch name every single time — without knowing this shortcut, you have to type the exact branch name accurately every time you go back and forth, which adds friction. In real teams, this shortcut meaningfully boosts efficiency in scenarios where you frequently bounce between your main working branch and a branch you're just checking.

Git
Try it (type this into the pseudo terminal)
git switch -

🧑‍💻 You can type this command into the Git pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)