Version Control

branch

A branch is a parallel line of work — your own private copy of the project where you can build something new without touching what everyone else relies on. The shared, official version usually lives on a branch called main; you make your own branch off it, tinker freely, and only fold your work back in once it's ready.

It's lighter than it sounds. A branch isn't a folder full of copied files — it's just a movable pointer to a commit. Making one is instant, and switching between branches is like flipping the project to a different version in place. This cheapness is on purpose: you're meant to branch often, even for a five-minute experiment.

The everyday rhythm is one branch per task. Fixing a bug? Branch. Trying a risky idea? Branch. If it works out, you merge it in; if it doesn't, you just throw the branch away and main never knew a thing. Your messes stay your own until you decide to share them.

$ git switch -c fix-login
Switched to a new branch 'fix-login'
$ git branch
* fix-login
  main

Make a branch and hop onto it in one step; the * marks where you are now.

main and master are just conventional names for the default branch — same role, different era. Newer repos lean toward main.

Also called
git branchfeature branchmainmaster
See also