GtGit · Lesson 3 of 8
Branches
A branch is a parallel timeline for your code. Experiment freely on a branch — if it works, merge it in; if not, delete it and main never knew.
The default branch is usually called main. Creating a branch is instant and free — git just writes a 43-byte file pointing at a commit. The universal workflow: never work directly on main; make a branch per feature or fix, merge it when done.
◆ Note
Older tutorials use 'git checkout -b name' — it still works, but 'git switch' (for branches) and 'git restore' (for files) split checkout's two jobs into clearly-named commands. Prefer them.
Older tutorials use 'git checkout -b name' — it still works, but 'git switch' (for branches) and 'git restore' (for files) split checkout's two jobs into clearly-named commands. Prefer them.