MEPX
Chapter 5 of 14All chapters

Chapter 5 of 14

Branches

A label that moves with your commits.

Creating and switching

A branch is a moving label on a commit. git switch -c feature creates one and moves you onto it, which is the modern spelling of git checkout -b.

  • git branch on its own creates the label and leaves you where you are.
  • git switch main moves you back without touching your commits.

Why branch at all

Branches keep unfinished work out of the shared line of history. They cost nothing in Git, so a branch per task is normal rather than ceremonial.