Git Branching Strategies Compared
Trunk-based, Git Flow, and GitHub Flow each suit different teams. Learn how they work, the trade-offs, and how to choose one.
By Velloreth
Why the strategy matters
A branching strategy is not a technical detail. It is a social contract about how code moves from a developer’s machine to production, and it determines how often people integrate, how conflicts are resolved, and how a release is cut.
The wrong strategy shows up as pain: long-lived branches that conflict constantly, releases that take a week of stabilisation, or hotfixes that cannot be applied to the version in production.
Trunk-based development
Everyone commits to main frequently. Feature branches are short-lived, often less than a day.
main ──●──●──●──●──●──●──●──●──►
\ / \ /
●──● ●●
The rules:
mainis always deployable.- Branches live less than a day or two.
- Incomplete work is hidden behind feature flags.
- Automated tests run on every commit.
Why it works. Frequent integration means conflicts are small and found early. The longer a branch lives, the more it diverges, and the harder the merge. Trunk-based development makes integration continuous rather than a periodic event.
The cost. It requires discipline and good test coverage. Without tests, committing to a shared main branch frequently means breaking it frequently. Feature flags add complexity, because you now have code paths that are deployed but not active.
When to use it. Continuous deployment, a small to medium team, and strong automated testing. This is the model most web companies use.
GitHub Flow
A lightweight model built around pull requests.
main ──●──●──────●──●──────●──►
\ / \ /
●──●──● ●──●
The rules:
mainis always deployable.- Branch from
mainfor any change. - Open a pull request for review.
- Merge to
mainafter review and passing checks. - Deploy from
main.
Why it works. It is simple enough to explain in a paragraph, and the pull request is a natural review point. There is no develop branch to keep in sync, and no release branch to manage.
The cost. It assumes you deploy from main, which suits a single production environment. It does not handle multiple supported versions well.
When to use it. Web applications with continuous deployment and a team that reviews pull requests. This is the default for most GitHub-hosted projects.
Git Flow
A structured model with long-lived branches.
main ──●──────────────●──────────●──►
\ / \ /
release \ ●──●──● \ ●──●
\ / \/
develop ──●───●──●──●──●──●──●──●──●──►
\ / \ /
feature ●───● ●●
The branches:
main— production releases only, tagged.develop— integration branch for the next release.feature/*— branched fromdevelop, merged back todevelop.release/*— branched fromdevelopwhen preparing a release, merged tomainand back todevelop.hotfix/*— branched frommainfor urgent fixes, merged to both.
Why it works. The release branch freezes a set of changes for stabilisation while development continues. This suits a scheduled release cycle, and it supports maintaining multiple versions.
The cost. It is complex. There are five branch types, and the merge rules are easy to get wrong. develop and main drift apart, and a hotfix must be merged to both. For a team deploying continuously, all of this is ceremony without benefit.
When to use it. Scheduled releases, multiple supported versions, or a product where a release must be stabilised before shipping. Desktop software, mobile apps with app-store review, and libraries with long support windows.
Comparing them
| Trunk-based | GitHub Flow | Git Flow | |
|---|---|---|---|
| Long-lived branches | main only | main only | main, develop |
| Branch lifetime | Hours | Days | Days to weeks |
| Release model | Continuous | Continuous | Scheduled |
| Multiple versions | No | No | Yes |
| Complexity | Low | Low | High |
| Test requirement | High | Medium | Medium |
| Feature flags | Usually | Sometimes | Rarely |
Choosing
Start from the release cadence.
Continuous deployment — trunk-based or GitHub Flow. The difference is mostly how short the branches are and whether feature flags are used.
Scheduled releases — Git Flow, or a simplified version with a release branch and no develop.
Multiple supported versions — Git Flow, because the release branch is what lets you patch an old version.
Then match the ceremony to the team. A two-person team does not need five branch types. A fifty-person team with parallel work in flight benefits from more structure.
Feature flags
Trunk-based development depends on feature flags to merge incomplete work.
if (flags.newCheckout) {
return <NewCheckout />;
}
return <OldCheckout />;
The flag lets you merge code that is not ready to be used. The code is deployed but inactive, so the branch can be short.
The cost. Flags accumulate. A flag that is never removed becomes a permanent branch in the code, and the two paths both need maintenance. The discipline is to remove the flag once the feature is fully rolled out.
Practical guidance
- Start simple. GitHub Flow is enough for most teams.
- Keep branches short. Long branches cause conflicts.
- Protect
main. Require review and passing checks. - Use feature flags to merge incomplete work.
- Remove flags once a feature is fully rolled out.
- Tag releases so you can find the exact commit.
- Match ceremony to cadence, not to fashion.
For the related guides, see git-merge-vs-rebase and git-commit-messages-guide. For the broader context, git-hooks-guide and semantic-versioning-explained.
Quotable summary
A branching strategy is a social contract about how code moves from a developer’s machine to production. Trunk-based development keeps branches short-lived and merges to main frequently, which suits continuous deployment and requires strong automated testing plus feature flags. Git Flow uses long-lived develop and release branches, which suits scheduled releases and multiple supported versions, at the cost of significant complexity. GitHub Flow is a lightweight model — branch from main, open a pull request, merge, deploy — and it is enough for most teams. The right choice depends on release cadence, team size, and how much parallel work is in flight, and the ceremony should match the cadence rather than the fashion.