FahamLah

Commands

git switch

git switch <branch> · git switch --detach <commit>

Risk: Safe

What it does

Moves HEAD to a branch, or to a commit.

When to use it

To visit an old commit, then come back.

Example

$ git switch main

Come back to main.

$ git switch --detach HEAD~2

Visit an old commit (detached HEAD).

$ git switch -

Go back to where you were.