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 mainCome back to main.
$ git switch --detach HEAD~2Visit an old commit (detached HEAD).
$ git switch -Go back to where you were.
Learn it in: Detached HEAD · Official docs