Branching Strategies and Pull Requests
Choose a branching model that supports frequent, safe releases and set up reviews and protections around it.
Beginner · about 3 hours · difficulty 2/5
Learn first: Git Fundamentals
How a team branches decides how often it can release. Long-lived branches mean painful merges and big-bang releases; short-lived branches keep changes small and reviewable.
Common models
- Trunk-based development: everyone merges small changes into
mainat least daily, often behind feature flags. Best fit for continuous delivery. - GitHub flow: short-lived feature branches plus pull requests into
main, which is always deployable. - GitFlow:
develop,releaseandhotfixbranches. Heavier; suited to versioned products with scheduled releases, rarely needed for web services. - Release branches for supporting multiple versions at once.
Guardrails
- Branch protection: required reviews, required status checks, no force pushes to
main. - CODEOWNERS to route reviews for infra or pipeline files to the right people.
- Merge strategies: merge commit, squash, or rebase. Pick one per repo.
- Monorepo vs polyrepo trade-offs, and path-based CI triggers for monorepos.
Pitfalls
Branches that live for weeks, "approve without reading" reviews, and CI that runs only after merge.
Good enough to move on: you can defend a branching model for a given team, configure branch protection with required checks, and keep your own branches under a day or two old.
Key concepts
- Trunk-based development
- GitHub flow
- GitFlow
- Pull request reviews
- Branch protection and required checks
- CODEOWNERS
- Monorepo vs polyrepo
Mini project
Configure a GitHub repo with branch protection on main, a CODEOWNERS file, a PR template and a required status check, then open and merge a PR through the full flow.
Check yourself
How does trunk-based development ship unfinished features without exposing them to users?
Free resources
- Trunk Based Development (trunkbaseddevelopment.com)
- About protected branches (GitHub)