Branches and pull requests
Beginner
10 min read
Work on a change in its own branch and get it reviewed before it joins the main line.
Why it matters
Branches let several people change the same project without stepping on each other. A pull request is where the change is reviewed and checked by CI before it is merged.
Where it fits
What you will learn
- Create a branch, commit to it and open a pull request.
- Resolve a simple merge conflict.
- Review a change usefully.
Before you start
- Git basics✓ Learned
A branch per change
Example
git switch -c fix/login-redirect # new branch from where you are
# ... edit, add, commit ...
git push -u origin fix/login-redirect
# then open a pull request on your Git host
git switch main
git pull # get what others merged
Reviewing
- The change does what the description says, and nothing unrelated.
- It has tests, and CI passed.
- Names and structure are clear to someone new.
- No secrets, debugging leftovers or commented-out code.
Tip: Small pull requests are reviewed faster and better. Split a large change into steps that each make sense alone.
A merge conflict means two branches changed the same lines. Git marks both versions in the file; you keep the right result, remove the markers, then git add and commit.
Official documentation and references
Documentation
- GitHub Docs — About protected branches ↗ Official · GitHub — Require reviews and passing checks before anything is merged.
- GitHub Docs — Pull requests ↗ Official · GitHub
Reference
- git-branch reference ↗ Official · Git project
Learn next
- Automated tests ›✓ Learned
Related topics
- Git basics✓ Learned
- CI/CD pipelines✓ Learned
- Automated tests✓ Learned
Done with this topic?
Reviewed 2026-10-23. Links go to the official documentation unless marked otherwise.