Chapter 2 · Practice 1 of 4
Work on short-lived branches off main
Why it matters
Long-lived branches drift away from main, collect painful conflicts and delay feedback. Short ones stay easy to merge and easy to review.
- Start each piece of work from an up-to-date main branch.
- Create one branch per piece of work.
- Merge it back within a few days.
- Delete the branch after it is merged, both on the remote and locally, so the branch list stays useful.
Name branches so others can tell what they are, for example fix/login-redirect or feat/export-csv, and include the issue number if your team uses one.
Example
git switch main
git pull
git switch -c fix/login-redirect
# ... work, commit ...
git push