Skip to content
6 min read·Lesson 3 of 10

Git Branching Strategies

Compare trunk-based development, GitFlow, and GitHub Flow — and understand how branching strategy affects release cadence, merge conflicts, and CI/CD pipeline design.

How a team manages branches in Git has a direct impact on integration pain, deployment frequency, and CI pipeline design. There is no single "correct" strategy — the right choice depends on your team size, release cadence, and deployment model.

Trunk-Based Development

In trunk-based development (TBD), all developers commit to a single shared branch — typically called main or trunk — either directly or via very short-lived feature branches (1–2 days maximum).

Key characteristics:

  • The trunk is always in a deployable state
  • Feature flags are used to hide incomplete features in production
  • CI runs on every commit; a broken trunk is fixed immediately
  • Enables very high deployment frequency — multiple times per day

Best for: Mature teams with strong automated test coverage and continuous deployment. Used by Google, Facebook, and most elite-performing software organisations according to DORA research.

GitHub Flow

GitHub Flow is a lightweight branch-based workflow:

  1. Create a branch from main for your feature or bug fix
  2. Commit and push changes to that branch
  3. Open a Pull Request (PR) for review
  4. Discuss, review, and iterate in the PR
  5. Merge to main when approved
  6. Deploy main immediately after merge

Best for: Teams that deploy continuously and want simplicity. Very common in open-source and SaaS products.

GitFlow

GitFlow (Vincent Driessen, 2010) uses multiple long-lived branches for different purposes:

BranchPurposeLifespan
mainProduction-ready code only; tagged with version numbersPermanent
developIntegration branch for features; next release candidatePermanent
feature/*Individual feature development, branched from developDays to weeks
release/*Release preparation; bug fixes only, no new featuresDays
hotfix/*Emergency production fixes, branched from mainHours

Best for: Products with scheduled versioned releases — mobile apps with app store submission, libraries with semantic versioning, enterprise software with quarterly release cycles. Not well-suited to continuous deployment.

The Merge Debt Problem

Every day a branch lives without merging to the trunk, it accumulates merge debt — divergence from the main codebase that must be resolved before the branch can be integrated. With large teams, long-lived branches become extremely expensive to merge and frequently cause integration conflicts.

The DORA research is unambiguous: teams using trunk-based development with short-lived branches have significantly higher deployment frequency and lower change failure rates than teams with long-lived branches.

Choosing a Strategy

FactorTrunk-BasedGitHub FlowGitFlow
Deploy frequencyMultiple/dayMultiple/dayWeekly/monthly
Release versioningVia tags/flagsVia tagsExplicit release branches
Team sizeAnySmall-mediumLarge, distributed
CI complexitySimpleSimpleComplex (multi-branch)
Feature flags neededYesSometimesRarely

Pull Requests and Code Review

Regardless of branching strategy, pull requests serve several functions beyond code review:

  • CI gate: PRs should not be mergeable if CI fails
  • Knowledge sharing: Team members stay aware of changes across the codebase
  • Documentation: PR descriptions explain the why behind a change
  • Security: A second pair of eyes catches vulnerabilities that automated tools miss

Require at least one approving review and passing CI before merging — this is table-stakes branch protection for any production codebase.

Key Takeaways

  • Trunk-based development keeps all developers committing to one main branch, using short-lived feature branches.
  • GitFlow uses long-lived branches (develop, release, hotfix) suited to scheduled versioned releases.
  • GitHub Flow is a lightweight alternative: branch, PR, merge to main, deploy.
  • Long-lived branches accumulate merge debt — the longer a branch lives, the harder it is to integrate.
  • Your branching strategy must align with your deployment model and release cadence.

Test your knowledge

Try exam-style practice questions to reinforce what you've learned.

Practice Questions →