Why We Switched From Gitflow to Trunk-Based Development (and How the Branching Rules Changed)

Gitflow did not fail us because it was wrong. It failed us because the shape of the work had changed underneath it, and nobody had noticed until the merges started hurting.

We ran Gitflow for years — main, a permanent develop, release/* branches cut for each version, hotfix/* when production caught fire, and a feature/* branch per ticket. It is a tidy model on a diagram. On a team shipping several times a week, it turned into a standing tax: long-lived branches that drifted for a fortnight, release branches that had to be merged back into both main and develop, and a hotfix dance that nobody could perform correctly under pressure. This is the account of why we moved to trunk-based development, and — the part most write-ups skip — exactly which branching and CI rules had to change to make it safe.

What actually broke

The pain was never Gitflow in the abstract. It was three concrete failure modes that repeated until they were predictable.

Free · 4 minutes

Is your engineering team shipping safely, or quietly accumulating risk?

Fourteen questions on how work gets from idea to production — cadence, testing, rollback, and the key-person risk in your delivery. Banded finding on screen, full sheet by email.

Long-lived branches drift. A feature branch open for two weeks is two weeks of everyone else’s changes that it has not seen. The merge at the end is not a merge, it is an archaeology project. The longer the branch lives, the larger the conflict surface, and the more likely the resolution quietly reintroduces a bug someone already fixed on develop.

The two-headed integration problem. With both main and develop as integration targets, every release and every hotfix has to be merged into both. Miss one and the branches diverge silently, so the next release ships a regression that was already fixed — just on the wrong branch. We lost more than one evening to a fix that existed but was not where the build looked for it.

Release cadence was gated by the model, not the work. Cutting a release branch, stabilising it, and merging it back is ceremony. It made sense when releases were quarterly and physical. It is pure friction when you want to ship a small change on a Tuesday afternoon.

The DORA research programme is blunt about this: teams that integrate to a single trunk, keep branches short-lived, and hold few active branches at a time are consistently the higher performers on throughput and stability. We were doing the opposite of all three.

The model we moved to

Trunk-based development is deceptively simple to describe. There is one long-lived branch — main, the trunk. Everyone branches off it for a short-lived feature branch, ideally something that merges back within a day, and never lives longer than a couple of days. There is no develop. There are no release/* branches held open for stabilisation. Every merge to main is expected to be releasable.

The obvious objection is the one everyone raises: how do you merge unfinished work to main many times a day without shipping half a feature? The answer is that you decouple deploy from release. Incomplete work merges behind a feature flag — off in production, on in the environments where you are still building it. The code integrates continuously; the behaviour is released when you flip the flag, not when you merge. If you have read our note on building a kill-switch with feature flags and drain modes, this is the same machinery pointed at delivery rather than incident response: the flag is the seam between “the code is present” and “the behaviour is live”.

Releases now come from a tag on main. When a commit on the trunk is the one we want in production, we tag it and the pipeline builds and deploys from that tag. There is no branch to stabilise, because stabilisation happens on the trunk continuously, on every merge.

The branching rules that had to change

Trunk-based development is not “push to main and hope”. It only works because the trunk is defended harder than any Gitflow branch ever was. On GitHub, using branch protection (or the newer rulesets, which do the same job with better scoping), the rules we enforce on main are:

  1. No direct pushes. Every change lands through a pull request, including the trunk’s own maintainers.
  2. Required status checks that must pass before merge — build, unit tests, linters, and the fast end of the integration suite. A red check blocks the merge; there is no override for convenience.
  3. “Require branches to be up to date before merging”, so a PR must be rebased or merged onto the current tip and re-tested before it can land. This is what stops a green PR from breaking the trunk because main moved while it sat in review.
  4. At least one required review, with stale approvals dismissed when new commits are pushed.
  5. Required linear history, so the trunk stays a readable line of squashed commits rather than a thicket of merge bubbles.

Once merge volume rose, requirement three became a bottleneck: everyone racing to re-base against a trunk that kept moving. GitHub’s merge queue solves it — it serialises pending PRs, tests each against the projected state of the trunk, and merges only those that pass, so the “up to date” rule no longer means humans hand-cranking rebases. If you are tightening up how developers reach the remote at all while you are in here, our piece on moving git remotes from HTTPS to SSH pairs naturally with this work.

What it costs, and who it is not for

The discipline is real and it is non-negotiable. Feature flags are technical debt with a shelf life: every flag is a branch in the runtime that has to be tested in both states and removed once the feature is fully live, or your codebase quietly fills with dead switches. Merge-daily is a habit, not a setting — it fails the moment someone decides their branch is “nearly done” and holds it another week. And a green trunk depends entirely on a test suite fast and trustworthy enough that people believe it; if CI is slow or flaky, the required checks become something to route around, and the model collapses.

Trunk-based development is not universal. If you ship versioned software that customers install and you genuinely support several releases in parallel, you need maintenance branches and Gitflow’s release model earns its keep. The teams it suits are the ones deploying a service they operate themselves, continuously — which is most of what we build and most of what our clients run. For everyone else, the honest test is the one Gitflow flattered us into ignoring: how old is your oldest open branch, and how much of the last outage came from a fix that was in the repository but not on the branch that shipped? If you already know the answer is uncomfortable, the branching model is not your real problem — the trunk is. And if any of this leaves you stranded mid-rebase, our note on getting back on a branch after a detached HEAD is the one to keep bookmarked.

Free interactive tool

Website compliance checklist

What your site has to do, based on what it actually does

Answer as much or as little as you like — the list builds as you go. Nothing is stored against your name and no email is required.

Most technology problems are not technology problems. They are control problems.

The systems exist. The investment has been made. The question is whether leadership can understand, direct, evidence, and sustain what those systems produce. Find out where control exists — and where it only appears to.