Skip to content

.tip

· one of the small things

git switch and git restore, not checkout

checkout does two unrelated jobs, and the dangerous one, throwing away your changes to a file, is the one that's easy to type by accident.

git switch feat/thing          # change branch
git switch -c feat/new         # create one
git restore src/app.ts         # discard changes to a file
git restore --staged src/app.ts  # unstage

They're the same operations, with names that say which one you meant.

git