Git Branching Strategies: Git Flow vs GitHub Flow vs Trunk-Based Development

Every team needs agreed rules for branches. This lesson explains the three most popular Git branching strategies, GitHub Flow, Git Flow and trunk-based development, with diagrams, pros and cons, a comparison table and guidance on choosing.

Advertisement

๐Ÿ“– What You’ll Learn: why teams need a branching strategy, GitHub Flow, Git Flow and its branch types, trunk-based development and feature flags, a side-by-side comparison, how to choose, environments, and how each strategy affects testing.


๐ŸŒณ Why You Need a Branching Strategy

When one person uses Git, almost anything works. When ten people commit every day, the team needs agreed rules: Which branches exist? Where do new features start? What gets deployed? How are urgent fixes released? That set of rules is a branching strategy (or Git workflow).

This lesson compares the three most popular strategies and shows how to choose. You should be comfortable with branches, merging and pull requests.


๐Ÿš€ GitHub Flow

The simplest strategy, created by GitHub:

main โ”€โ”€โ”€โ—โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ—โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ—โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ—โ”€โ”€โ”€โ”€ (always deployable)
         \     /             \        /
          โ—โ”€โ”€โ”€โ—  feature/a    โ—โ”€โ”€โ—โ”€โ”€โ”€โ—  feature/b
              PR + review         PR + review

Rules:

  1. main is always deployable.
  2. For any change, create a descriptive branch from main.
  3. Commit and push regularly; open a pull request early.
  4. Review, discuss and let CI run.
  5. Merge to main and deploy (often automatically).
ProsCons
Very simple; few branchesNeeds strong CI and automated tests
Fast feedback, continuous deliveryNot ideal for supporting several released versions at once

Best for: web apps and SaaS with continuous deployment.


๐Ÿ—๏ธ Git Flow

A structured model with long-lived branches, introduced by Vincent Driessen in 2010:

BranchLifetimePurpose
mainPermanentProduction releases only, each tagged (v2.4.0)
developPermanentIntegration branch for the next release
feature/*TemporaryNew features, branched from and merged back into develop
release/*TemporaryStabilise a release (bug fixes, versioning); merged into main and develop
hotfix/*TemporaryUrgent production fixes from main; merged into main and develop
main     โ—โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ—โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ—   (v2.4.0)   (v2.4.1)
          \                    / \      /
release    \        โ—โ”€โ”€โ”€โ—โ”€โ”€โ”€โ”€โ”€โ—   \    /
            \      /               hotfix
develop      โ—โ”€โ”€โ—โ”€โ”€โ—โ”€โ”€โ”€โ—โ”€โ”€โ”€โ—โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ—โ”€โ”€โ—
              \   /     \  /
feature        โ—โ”€โ—       โ—โ—
ProsCons
Clear separation of development and productionMany branches and merges; more overhead
Supports scheduled releases and multiple versionsSlower feedback; long-lived branches cause bigger conflicts
Natural fit for QA phases on release branchesConsidered heavy for continuous delivery

Best for: products with versioned, scheduled releases (mobile apps, installed software, regulated environments).


โšก Trunk-Based Development

Everyone integrates into one main branch (the trunk) at least daily:

  • Very short-lived branches (hours, at most a day or two), or direct commits to main for small teams.
  • Unfinished features are hidden behind feature flags instead of long branches.
  • Heavy reliance on automated tests that run on every change.
  • Releases are cut from main (sometimes via short-lived release branches).
ProsCons
Minimal merge conflicts; continuous integration in the truest senseRequires excellent test automation and discipline
Fastest deliveryFeature flags add complexity
Used by many high-performing engineering organisationsHarder for beginners and teams with weak CI

Best for: experienced teams with mature CI/CD and strong automated test suites.


โš–๏ธ Side-by-Side Comparison

GitHub FlowGit FlowTrunk-Based
Long-lived branchesmainmain + developmain (trunk)
Feature branch lifetimeDaysDays to weeksHours to a day
Release styleContinuousScheduled versionsContinuous
ComplexityLowHighLow process, high engineering discipline
HotfixesNormal PR to mainhotfix/* branchFix on trunk, cherry-pick if needed
Dependence on test automationHighMediumVery high

๐Ÿงญ How to Choose

  • Small team, web app, deploys often: GitHub Flow.
  • Versioned product, multiple supported releases, formal QA phase: Git Flow (or a lighter variant).
  • Mature DevOps team, strong CI, feature flags: trunk-based development.
  • Several environments (dev, QA, staging, prod): many teams add environment branches or, better, promote the same build through environments with a deployment pipeline (deploy with GitHub Actions).

๐Ÿ’ก Tip: Whatever you choose, write it down in CONTRIBUTING.md, enforce it with branch protection, and keep branches short-lived. Long-running branches are the main source of painful merge conflicts.


๐Ÿงช What It Means for Testers

StrategyWhere testers test
GitHub FlowOn each PR (preview environments, CI tests) and continuously on main
Git FlowFeature testing on develop; regression on release/* before merging to main
Trunk-basedMostly automated on every commit; exploratory testing behind feature flags

Automated tests running on every pull request (for example Playwright in GitHub Actions) are essential for all three.


๐Ÿ“ Assignment

  1. In git-practice, simulate GitHub Flow: two feature branches, two PRs, merge both to main.
  2. Simulate Git Flow: create develop, a feature/* branch merged into develop, a release/0.3.0 branch merged into main and develop, and a tag v0.3.0.
  3. Simulate a hotfix in Git Flow and merge it into both main and develop.
  4. Write a one-page branching guide for a team of five testers and developers who deploy weekly. Which strategy would you choose and why?

โ“ FAQ

๐Ÿค” What is a Git branching strategy?

An agreed set of rules for how a team creates, names, merges and releases branches, such as GitHub Flow, Git Flow or trunk-based development.

๐Ÿค” What is the difference between Git Flow and GitHub Flow?

Git Flow uses long-lived main and develop branches plus feature, release and hotfix branches for scheduled releases. GitHub Flow uses only main plus short-lived feature branches merged through pull requests and deployed continuously.

๐Ÿค” What is trunk-based development?

A strategy where everyone integrates small changes into one main branch at least daily, using very short-lived branches and feature flags.

๐Ÿค” Which branching strategy is best?

It depends on your release style and test automation. GitHub Flow suits most web teams; Git Flow suits versioned releases; trunk-based suits mature teams with strong CI.

๐Ÿค” Is Git Flow still used?

Yes, especially for versioned products, but many teams doing continuous delivery have moved to GitHub Flow or trunk-based development.


๐ŸŽฏ Next Steps

๐ŸŽฌ Learn Git and GitHub step by step: watch the series on YouTube!

Subscribe to SqaToolsByDY • Practice on sqatools.in

3 thoughts on “Git Branching Strategies: Git Flow vs GitHub Flow vs Trunk-Based Development”

Leave a Comment