Skills › 💻 Terminal & git

Jump back to the last branch with git switch -

Bouncing between a feature branch and main? - means "the branch I was just on," so you never type its name.

⏱ 15s

  1. Run git switch main (or any other branch) to leave your feature branch.
  2. Run git switch - to go straight back.
  3. Run git switch - again to flip back the other way.

Tip: - is short for @{-1}. Use git switch @{-2} to go back two branches.

Try it now: In any repo with two branches, switch to one, then run git switch - twice and watch git branch change.

Practice in the feed →

Next crumbs

Sources