Branching Models Compared: Trunk-Based, GitFlow, GitHub Flow
Fast recall
Quick revision
Core answer
Practical understanding of CI/CD branching strategy and its impact on velocity
Adopting GitFlow for a SaaS web app — the develop/release branches add overhead with no benefit when there are no released versions
Discuss branch lifetime as the key metric, the relationship between trunk-based and feature flags, and the merge-conflict cost of long-lived branches
Interview-ready guide
Interview answer
Branching strategy isn't a stylistic choice — it sets the ceiling on how often you can deploy. The metric that matters is branch lifetime; everything else is secondary.
Trunk-based development — the modern SaaS default
- One long-lived branch (main); short-lived feature branches (less than a day, often hours); incomplete work hidden behind feature flags
- Used by Google, Facebook, Netflix, Stripe — any team that ships many times per day
- Requires strong CI (fast comprehensive tests) and discipline: when main breaks, the team stops to fix it before merging anything else
- Requires feature flags as a first-class tool — LaunchDarkly, Unleash, OpenFeature, or in-house — because you can't merge half-built features without breaking production
GitFlow — for versioned shipped software
- Multiple long-lived branches: master (production), develop (next release), feature/, release/, hotfix/*
- Feature branches off develop, merge back; release branches cut from develop and stabilized then merged to master with a tag; hotfixes branch from master and back-merge to develop
- Optimized for software with explicit released versions — open-source libraries, desktop apps, embedded firmware, regulated software with formal release sign-off
- Anti-pattern for SaaS: a continuously-deployed service has no concept of a release, so the develop and release branches add overhead with no benefit
GitHub flow — the simple middle ground
- Main plus short-lived feature branches via PR; no develop, no release branches
- Used by GitHub itself and most small-to-medium SaaS teams; a stepping stone toward full trunk-based for teams not yet ready to ditch PR review as the gating step
The metric that matters — branch lifetime
- A 2-week feature branch creates massive merge conflicts when merged; a 4-hour branch has minimal drift
- The single biggest velocity unlock is shrinking branch lifetime; the model name (trunk-based vs GitHub flow) is secondary
- Long-lived branches mask CI gaps because main only sees breakage at merge time; trunk-based forces CI maturity
Common mistakes
- Adopting GitFlow for a SaaS web app — the develop and release branches solve a problem you don't have
- Adopting trunk-based without feature-flag tooling — incomplete work either ships broken or sits on long branches, defeating the purpose
- Forgetting to back-merge GitFlow hotfixes from master to develop — the bug returns in the next release
- Treating branch model as the goal rather than as a means to faster, safer deploys
The default recommendation
- New SaaS team: GitHub flow now, trunk-based as deploy frequency grows past once-per-day
- Library or desktop app with versioned releases: GitFlow makes sense
- Mature SaaS engineering org: trunk-based with feature flags, treating main as always-deployable
Branching Models Compared: Trunk-Based, GitFlow, GitHub Flow
Direct Answer
Trunk-based wins for teams shipping multiple times a day with strong CI: short-lived branches (<1 day), feature flags for incomplete work, and main is always deployable — the model used by Google, Facebook, and most modern SaaS teams. GitFlow (develop, release, feature, hotfix branches) wins for software with explicit released versions — desktop apps, libraries, embedded firmware. GitHub flow (main + short-lived feature branches via PR) is the simple middle ground — great for small teams.
Common Mistakes & Pitfalls
Adopting GitFlow for a SaaS web app — the develop/release branches add overhead with no benefit when there are no released versions
Check your understanding
Answer these without looking back at the article.
- What are the operational requirements (CI, feature flags, observability) for adopting trunk-based development?
- How do you migrate a team from GitFlow to trunk-based without disrupting in-flight work?
- What's the role of feature flags in enabling continuous deployment?
- When does GitFlow's hotfix branch model break down?
Related interview prep categories
1Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.