10 · Version Control

Checkout / Switch

Move between branches or commits

The command that moves you onto a different branch (or back to an old commit), swapping your files to match. Newer git splits it into “switch” for branches and “restore” for files.

Concrete example

“git checkout main” puts you back on main; “git switch -c fix” creates and moves to a new branch.

Why it matters

How you actually hop between the parallel lines of work that branches create.