Skip to content
Velloreth
Developer Tools 5 min read

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

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:

  • main is 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:

  • main is always deployable.
  • Branch from main for any change.
  • Open a pull request for review.
  • Merge to main after 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 from develop, merged back to develop.
  • release/* — branched from develop when preparing a release, merged to main and back to develop.
  • hotfix/* — branched from main for 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-basedGitHub FlowGit Flow
Long-lived branchesmain onlymain onlymain, develop
Branch lifetimeHoursDaysDays to weeks
Release modelContinuousContinuousScheduled
Multiple versionsNoNoYes
ComplexityLowLowHigh
Test requirementHighMediumMedium
Feature flagsUsuallySometimesRarely

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.

Frequently asked questions

What is trunk-based development?
A strategy where everyone commits to a single main branch frequently, with short-lived feature branches that live less than a day or two. It relies on feature flags to hide incomplete work and on strong automated testing.
Is Git Flow still relevant?
It is relevant for teams with scheduled releases and multiple supported versions, such as desktop software or libraries with long support windows. For web applications that deploy continuously, it adds ceremony without benefit.
What is the difference between Git Flow and GitHub Flow?
Git Flow has long-lived develop and release branches plus hotfix branches. GitHub Flow has only main and short-lived feature branches, and it deploys from main. GitHub Flow is much simpler.
How long should a feature branch live?
As short as possible. A branch that lives for days accumulates merge conflicts and diverges from main. Aim for less than a day, and use feature flags to merge incomplete work safely.
What is a release branch for?
It freezes a set of changes for a release while development continues on main. It lets you stabilise a release without blocking new work, and it is the main reason to use Git Flow.
How do I choose a branching strategy?
Start from your release cadence. Continuous deployment suits trunk-based or GitHub Flow. Scheduled releases with supported versions suit Git Flow. Then match the ceremony to the team's size and discipline.