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.
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/*andhotfix/*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 development | GitHub Flow | Git Flow | |
|---|---|---|---|
| Long-lived branches | main only | main only | main and develop |
| Short-lived branches | Hours to about two days | One per change, merged via PR | feature/*, release/*, hotfix/* |
| How code reaches main | Small commits or tiny PRs, often daily | Pull request, review, merge, deploy | Feature → develop → release/* → main + tag |
| Unfinished work | Hidden behind feature flags | Kept on the branch, or behind flags | Kept on the feature branch |
| Best for | Continuous delivery, strong CI | Small and medium web teams | Versioned products, several supported versions |
| Main risk | Needs good tests and flags | Branches that quietly grow old | Slow 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:
- Conflicts are small. You resolve them while the change is still fresh in your head.
- CI tests the real product. Every merge tests the code that will actually ship, not a private fork of it.
- Releases are boring. There is no "merge week". Any green commit on
maincan 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:
mainholds released code only. Every merge into it is tagged with a version.developis the integration branch for the next release.
It adds three kinds of supporting branch:
feature/*branches start fromdevelopand merge back into it.release/*branches start fromdevelopto freeze and polish a version. They merge intomain(tagged) and back intodevelop.hotfix/*branches start frommainto patch production. They merge intomain(tagged) and back intodevelop.
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.
| Need | GitHub | GitLab |
|---|---|---|
Block direct pushes and force pushes on main | Protected branches or rulesets | Protected branches |
| Require review and green CI | Required reviews and required status checks | Approval rules, "Pipelines must succeed" |
Test each change against the latest main before merging | Merge queue | Merge 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_grouptrigger. 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":
- 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.ybranches offmain. - Do you deploy from
mainseveral times a day and trust your test suite? Use trunk-based development with feature flags and a merge queue. - 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
- GitHub flow, GitHub Docs
- About protected branches, About rulesets, Managing a merge queue, GitHub Docs
- Protected branches and Merge trains, GitLab Docs
- Trunk-based development, DORA
- Short-lived feature branches, trunkbaseddevelopment.com
- A successful Git branching model, Vincent Driessen
- Feature Toggles, Pete Hodgson on martinfowler.com
UniqBlog Desk · Editors
The editors of UniqBlog. Tested tutorials and tech news for working developers.
Further along the line

Git rebase vs merge: when to use each, with a demo
Git rebase vs merge with a reproducible demo: how each shapes history, when to rebase, the golden rule, safe force-pushes, and git pull vs fetch.

Kubernetes vs Docker: which one do you actually need?
Kubernetes vs Docker is not either-or: Docker builds and runs containers, Kubernetes schedules them across machines. Here is when each layer earns its cost.

Docker Compose volumes: bind mounts, tmpfs and backups
Docker Compose volumes explained with a tested compose file: when to use named volumes, bind mounts or tmpfs, how to name them, and how to back up and restore one.

PostgreSQL vs MySQL in 2026: which database should you pick?
PostgreSQL vs MySQL compared on current versions: JSON, CTEs, window functions, extensions, replication, licensing and cost, with SQL we ran on both.