I just learned a cool git thing.
You can use git switch [revision] -C [branchname]
to move a branch to a specific revision and check it out in a single operation. This works even if you currently have that branch checked out.
Unlike git reset
, which can do something similar, this operation is safe. If you have uncommitted changes, it'll fail instead of clobbering them.
So at this point I'd always recommend using git restore
and git switch
instead of git checkout
and git reset