Git Branching: There's No One Right Way
Every team argues about branching strategies at some point. The truth is there's no universal best approach — it depends on your team size, release cadence, and deployment model. Here are the three most popular strategies with honest trade-offs.
GitHub Flow (Simple)
main ─────●─────●─────●─────●─────●─────
\ /
feature ●How it works:
- Branch off
main - Make commits, push to remote
- Open a pull request
- Get code review
- Merge to
main mainis always deployable
git checkout -b feature/add-search
# ... work, commit, push ...
git push -u origin feature/add-search
# Open PR on GitHub, get review, merge| Pros | Cons |
|---|---|
| Dead simple — one branch rule | No separation between "released" and "in progress" |
| Fast iteration | Requires CI/CD maturity (auto deploy on merge) |
| Works great for SaaS / web apps | Harder for mobile apps with release cycles |
Best for: Small teams, SaaS products, continuous deployment.
Gitflow (Complex)
main ─────●───────────────●───────
| |
release | ●────● |
| / \ |
develop ──●──●──●────●────●──●───●──
\ / \ /
feature ●───● ●───● How it works:
main— production releases only, tagged with versionsdevelop— integration branch, always has the latest featuresfeature/*— branch from develop, merge back to developrelease/*— branch from develop when ready to release, bug fixes onlyhotfix/*— branch from main for urgent production fixes
| Pros | Cons |
|---|---|
| Clear separation of concerns | Too many branches and ceremony |
| Explicit release management | Merge conflicts pile up in develop |
| Good for versioned software | Slow — features wait for release windows |
Best for: Packaged software, mobile apps with app store releases, teams with QA stages.
Trunk-Based Development (Fast)
main ──●──●──●──●──●──●──●──●──●──
\ / \ /
● ●
(short-lived branches, < 1 day)How it works:
- Everyone commits to
main(or very short-lived branches merged same-day) - Feature flags hide incomplete work
- CI runs on every commit
- Releases are tags on main, or continuous deployment
# Short-lived branch (merged within hours)
git checkout -b fix/typo-in-header
git commit -am "Fix typo in header component"
git push -u origin fix/typo-in-header
# PR created, reviewed, merged same day
# Or commit directly to main (with CI protection)
git commit -am "Add search endpoint behind feature flag"
git push origin main| Pros | Cons |
|---|---|
| Fastest feedback loop | Requires excellent CI/CD and testing |
| No merge hell | Feature flags add complexity |
| Used by Google, Meta, etc. | Requires team discipline |
Best for: Experienced teams, continuous deployment, microservices.
Comparison
| Factor | GitHub Flow | Gitflow | Trunk-Based |
|---|---|---|---|
| Complexity | Low | High | Low |
| Branch lifespan | Days | Days to weeks | Hours |
| Merge conflicts | Occasional | Frequent | Rare |
| Release model | Continuous | Scheduled | Continuous |
| CI/CD maturity needed | Medium | Low | High |
| Team size | 2-15 | 5-50+ | Any (with discipline) |
Practical Tips
- Keep branches short-lived. Any branch open more than 3 days is a merge conflict waiting to happen.
- Delete branches after merging.
git branch -d feature/doneand enable auto-delete on GitHub. - Protect main. Require PR reviews and passing CI before merge.
- Rebase before merging to keep history clean:
git rebase mainon your feature branch. - Use conventional commits for automated changelogs:
feat:,fix:,chore:.
Git reference: Git Cheatsheet — all common git commands, searchable and categorized.