Git branching strategy: trunk-based, GitHub Flow or Git Flow

A git branching strategy decides how fast your code reaches main. Compare trunk-based development, GitHub Flow and Git Flow, and pick one in five minutes.

Tools Stop 1 of 2 By UniqBlog Desk 30 November 2026 Updated 1 December 2026 6 min read

Soft 3D illustration: an amber trunk railway track across a grey board, with grey side tracks branching off and rejoining it at two round stations

For most teams that deploy a web app continuously, the best git branching strategy is trunk-based development or GitHub Flow: one long-lived main, short-lived branches that merge within a day or two, and CI that keeps main releasable. Use Git Flow only when you ship explicitly versioned software and must support several releases at once.

The commands below were tested with Git 2.53.0 on 2026-12-01. Platform features are checked against the GitHub and GitLab docs as of December 2026.

Key takeaways

  • Fewer and shorter branches mean fewer painful merges. DORA recommends three or fewer active branches.
  • GitHub Flow is trunk-based development with pull requests. It is the right default for a small team.
  • Git Flow adds develop, release/* and hotfix/* branches. Its own author says it suits versioned software and teams that support several releases, not continuous delivery.
  • Branch protection (or rulesets), required CI checks, a merge queue and feature flags make short-lived branches safe.

What is a git branching strategy?

It is the team agreement on which branches exist, how long they live, and how code moves from a laptop to production. The agreement matters more than the tool. Git will happily let ten people keep ten month-old branches, then leave you a week of conflicts at release time.

Three strategies cover almost every team.

Trunk-based developmentGitHub FlowGit Flow
Long-lived branchesmain onlymain onlymain and develop
Short-lived branchesHours to about two daysOne per change, merged via PRfeature/*, release/*, hotfix/*
How code reaches mainSmall commits or tiny PRs, often dailyPull request, review, merge, deployFeature → develop → release/* → main + tag
Unfinished workHidden behind feature flagsKept on the branch, or behind flagsKept on the feature branch
Best forContinuous delivery, strong CISmall and medium web teamsVersioned products, several supported versions
Main riskNeeds good tests and flagsBranches that quietly grow oldSlow integration, merge pain

What is the best branching strategy for a small team?

GitHub Flow. GitHub's own guide lists six steps: create a branch, make changes, open a pull request, address review comments, merge, and delete the branch. There is one rule to keep: the branch lives for days, not weeks.

Here is the loop as commands. It keeps history linear by rebasing before the merge:

git switch -c feat/login-button
# ...edit, then commit small steps
git commit -am "Add login button behind flag"

git fetch origin
git rebase origin/main            # pick up everyone else's work first
git push -u origin feat/login-button
# open the pull request, get a review, let CI pass, merge in the UI

git switch main && git pull --ff-only
git branch -d feat/login-button

A small team does not need a develop branch. main is what you deploy, and every merged pull request is a candidate release.

How does trunk-based development reduce integration issues?

Integration pain grows with the time between merges. Two branches that each drifted for three weeks conflict in many places. Two branches that drifted for three hours rarely conflict at all.

The trunk-based development site says a feature branch "should only last a couple of days". DORA goes further. Its guidance is that branches "typically last no more than a few hours". It also says small, frequent merges reduce "the complexity of merging events".

In practice that gives you three things:

  1. Conflicts are small. You resolve them while the change is still fresh in your head.
  2. CI tests the real product. Every merge tests the code that will actually ship, not a private fork of it.
  3. Releases are boring. There is no "merge week". Any green commit on main can go out.

So how do you merge half-built features every day? You hide them. A release toggle keeps the code path off in production until it is ready. Pete Hodgson's feature toggles article describes these as "feature flags used to enable trunk-based development". The simplest version is a boolean from config:

// config decides; the code ships either way
if (flags.newCheckout) {
  renderNewCheckout();
} else {
  renderCheckout();
}

Delete the flag and the old path once the feature is live. Old flags are debt.

What are Git Flow's branches, and when is it the right choice?

Git Flow was published by Vincent Driessen in 2010. It uses two long-lived branches:

  • main holds released code only. Every merge into it is tagged with a version.
  • develop is the integration branch for the next release.

It adds three kinds of supporting branch:

  • feature/* branches start from develop and merge back into it.
  • release/* branches start from develop to freeze and polish a version. They merge into main (tagged) and back into develop.
  • hotfix/* branches start from main to patch production. They merge into main (tagged) and back into develop.

You do not need the git-flow extension. Plain Git does it:

git switch -c release/1.4.0 develop
echo 1.4.0 > VERSION && git commit -am "Bump version to 1.4.0"

git switch main
git merge --no-ff release/1.4.0 -m "Release 1.4.0"
git tag -a v1.4.0 -m "1.4.0"

git switch develop
git merge --no-ff release/1.4.0 -m "Merge release/1.4.0 back"
git branch -d release/1.4.0

The model's author added a note in 2020. If your team does continuous delivery, he suggests "a much simpler workflow (like GitHub flow)". Git Flow "may still be as good of a fit" if you build "software that is explicitly versioned" or "need to support multiple versions of your software in the wild".

So Git Flow fits mobile apps going through store review, libraries with LTS lines, firmware and on-premise products. It does not fit a SaaS web app that deploys ten times a day.

Which tools make a branching strategy stick?

A strategy only exists when the platform enforces it. Here is what each feature does, with names and availability taken from the official docs as of December 2026.

NeedGitHubGitLab
Block direct pushes and force pushes on mainProtected branches or rulesetsProtected branches
Require review and green CIRequired reviews and required status checksApproval rules, "Pipelines must succeed"
Test each change against the latest main before mergingMerge queueMerge trains (Premium, Ultimate)

A few details from the docs are worth knowing:

  • On GitHub Free, protected branches and rulesets work on public repositories only. Private repositories need GitHub Pro, Team or Enterprise.
  • Several rulesets can apply to one branch, and "the most restrictive version of the rule applies". Only one classic branch protection rule applies at a time.
  • Merge queues are available in public repositories owned by an organization, and in private repositories owned by organizations on GitHub Enterprise Cloud.
  • If your required checks run in GitHub Actions, you must add the merge_group trigger. Without it, the checks never run for queued pull requests.
# .github/workflows/ci.yml
on:
  pull_request:
  merge_group:

A merge queue gives you what "require branches to be up to date" gives you, without making every author rebase and wait. It pays off once several people merge into the same branch every day.

Which branching strategy should you pick?

Answer these in order and stop at the first "yes":

  1. Do you maintain several released versions at once (LTS lines, app store builds, customer-installed versions)? Use Git Flow, or a lighter variant with release/x.y branches off main.
  2. Do you deploy from main several times a day and trust your test suite? Use trunk-based development with feature flags and a merge queue.
  3. Anything else, which covers most small teams and most web apps: use GitHub Flow. Protect main, require one review and green CI, and delete branches after merging.

Whichever you choose, write it down in CONTRIBUTING.md in three lines: branch names, maximum branch age, and how a change reaches production.

Sources

UniqBlog Desk · Editors

The editors of UniqBlog. Tested tutorials and tech news for working developers.

Further along the line