Dev tools

Trunk Based Development: How It Works in Practice

Trunk based development explained: how it works, trunk based development vs GitFlow, feature flags, release branches, a worked example and how to adopt it.

By OmniAI Editorial · Nov 22, 2026 · 11 min read

Trunk based development is a source-control practice in which every developer integrates small changes into one shared main branch, the trunk, at least once a day, instead of working for weeks on long-lived feature branches. Work stays releasable at all times: automated tests run on every change, unfinished features hide behind feature flags, and releases are cut from the trunk. Google's DORA research lists it as a key capability of high-performing software teams, because it avoids painful merges and lets teams deliver continuously.

This guide explains how trunk based development works day to day, trunk based development vs GitFlow and GitHub flow, trunk based development with feature flags and with release branches, the prerequisites, a worked trunk based development example, the evidence behind it, and how to adopt it without breaking production.

What Is Trunk Based Development?

The "trunk" is the single shared branch everyone integrates into, usually called main or master in Git. In trunk based development:

  • developers commit small changes to the trunk frequently, at least daily;
  • any branches are short-lived, typically hours or a day or two, then merged and deleted;
  • the trunk is always in a working, deployable state, protected by automated tests;
  • incomplete features are hidden with feature flags or other techniques rather than kept on separate branches.

DORA, the long-running research program on software delivery now part of Google Cloud, describes the practice in measurable terms. Teams achieve higher delivery and operational performance when they have three or fewer active branches in the repository, merge branches to trunk at least once a day, and don't have code freezes or integration phases.

There are two common styles:

  • Direct-to-trunk: small, experienced teams commit straight to main, relying on pair programming and strong tests.
  • Short-lived branches with pull requests: the more common style in larger teams; each change gets a branch, a quick review and automated checks, then merges to trunk within a day or so.

How Trunk Based Development Works

A typical day for a developer:

  1. Pull the latest trunk first thing and work from it.
  2. Make a small, self-contained change: a refactor, one slice of a feature, a test, a bug fix.
  3. Run tests locally, then push to a short-lived branch.
  4. Open a small pull request. Because it's small, review takes minutes, not days.
  5. CI runs automatically on the change: build, unit tests, integration tests, linting, security checks.
  6. Merge to trunk once checks pass and a reviewer approves. Many teams use a merge queue so each change is tested against the latest trunk before it lands.
  7. Deploy: the trunk is deployed automatically, or released on a schedule, with unfinished features switched off by flags.

The key habit is slicing work small. A two-week feature becomes ten or twenty mergeable steps, each of which leaves the trunk working.

A thick ink trunk line with six short loops below it, and one long light branch arching high above that rejoins the trunk at an orange dot.
Short-lived branches rejoin the trunk within a day; long-lived branches pile up merge pain.

Trunk Based Development vs GitFlow

GitFlow, described by Vincent Driessen in 2010, uses several long-lived branches: main for releases, develop for integration, plus feature, release and hotfix branches. It was designed for software shipped in versions, where several releases may be supported at once.

Trunk based developmentGitFlowGitHub flow
Long-lived branchesJust trunk (plus optional release branches)main and develop, plus release and hotfix branchesJust main
Feature branch lifetimeHours to a day or twoDays to weeks or longerShort to medium
Integration frequencyContinuous, at least dailyWhen features are finishedWhen each pull request is merged
Unfinished workHidden behind feature flagsKept on feature branchesKept on branches until ready
Release processDeploy trunk continuously, or cut release branches from trunkRelease branches stabilised, then merged to main and developDeploy main
Merge conflictsSmall and frequentLarge and painful near releasesModerate
Best fitContinuous delivery, web services, teams with strong CIVersioned software with several supported releasesSmall teams and web apps

Driessen himself added a note to his original post in 2020: web apps are typically continuously delivered, and for teams doing continuous delivery he suggested adopting a much simpler workflow, like GitHub flow, instead of shoehorning GitFlow into the team. GitFlow still suits products such as desktop or embedded software where several versions are maintained in parallel.

GitHub flow and trunk based development are close cousins. The difference is mostly emphasis: trunk based development insists on very short branch lifetimes and daily integration, and uses feature flags so large features never need long-lived branches.

Trunk Based Development With Feature Flags

Trunk based development with feature flags is what makes the practice work for large features. A feature flag is a runtime switch that turns a code path on or off without a new deployment.

if flags.is_enabled("new-checkout", user=current_user):
    return new_checkout(cart)  # merged to trunk, hidden from most users
return old_checkout(cart)

Flags let teams:

  • merge incomplete work safely, because it's switched off in production;
  • separate deployment from release: code ships continuously, and the business decides when users see it;
  • roll out gradually to internal users, then a small percentage of customers, then everyone;
  • kill a bad feature instantly without a rollback deployment.

Flags have costs. Each one adds a branch in the code and a configuration to test. Teams that never remove flags accumulate "flag debt": confusing, half-dead code paths. Give every release flag an owner and a removal date, and delete it once the feature is fully launched.

Trunk Based Development With Release Branches

Not every team deploys continuously. Mobile apps go through app-store review, and enterprise software ships on schedules. Trunk based development with release branches handles this:

  1. When a release is due, create a release branch from trunk, for example release/2.14.
  2. Test and ship from that branch.
  3. Fix bugs on trunk first, then cherry-pick the fix to the release branch. Never develop on the release branch and merge back, which reintroduces long-lived divergence.
  4. Delete or archive the release branch when that version is no longer supported.

Release branches are created by release managers, not developers, and receive only cherry-picked fixes. Day-to-day development stays on trunk.

Other Techniques That Keep the Trunk Releasable

  • Branch by abstraction: to replace a large component, introduce an interface in front of the old implementation, build the new implementation behind it in small steps, switch callers over, then delete the old one, all on trunk.
  • Dark launching: deploy new backend code and send it real traffic in the background without showing results to users, to test performance safely.
  • Keystone interfaces: build the back end of a feature first and add the user-facing entry point (the "keystone") last, so the feature is invisible until it's complete.
  • Small, reversible database changes: expand the schema first, migrate code, then contract, so every step works with both old and new code.

Prerequisites for Trunk Based Development

Trunk based development removes the safety net of isolation, so it needs other safety nets:

PrerequisiteWhy it matters
Fast, reliable CI on every changeBroken code must be caught within minutes, before others pull it
A strong automated test suiteUnit, integration and a focused set of end-to-end tests guard the trunk
Quick code reviewSmall changes waiting days for review defeat the purpose
A merge queue or required up-to-date checksEnsures each change is tested against the latest trunk
Feature flagsLets large features merge before they're finished
Fast rollback or fix-forwardMistakes reach production sooner, so recovery must be quick
Team habitsSlicing work small and integrating daily is a skill teams build deliberately

Our guide to end-to-end testing covers how to build the top layer of that safety net without making CI slow.

Trunk Based Development Example

Here's a trunk based development example. A team adds a new checkout flow, which would take about two weeks on a long-lived branch. Instead:

DayChange merged to trunkVisible to users?
1Add the new-checkout feature flag (off) and an empty new checkout moduleNo
1Refactor the payment client behind an interface (branch by abstraction)No
2Build the new cart summary component with unit testsNo (flag off)
3Add the new address form and validationNo
4Wire the new flow to the payment interface; integration tests addedNo
5Turn the flag on for employees only; dogfooding beginsInternal users
6Fix two bugs found internally, each merged within hoursInternal users
7Enable for 5% of customers; watch error rates and conversion5%
9Enable for 50%, then 100%Everyone
12Remove the flag and the old checkout codeEveryone, old path gone

The trunk was releasable every day. No change took more than a few hours to review, conflicts with other teams' work were caught within a day, and the risky moment was a flag flip that could be reversed instantly, not a giant merge the night before release.

A light half-dial gauge with an ink needle beside three grey bars of increasing width, the widest outlined in orange.
Feature flags turn a release into a gradual, reversible rollout.

Benefits and Evidence

  • Fewer, smaller merge conflicts. Integrating daily means conflicts are caught while they're small. Our guide to git merge conflicts shows how much easier small conflicts are to resolve.
  • Continuous integration in practice. DORA calls trunk based development a required practice for continuous integration: if code isn't merged frequently, it isn't really integrated.
  • Faster feedback. Bugs surface within hours of being written, not weeks later in a stabilisation phase.
  • No code freezes. Without big integration events, there's no need to stop work before releases.
  • Better delivery performance. DORA's research finds that teams following these practices achieve higher software delivery and operational performance, meaning delivery speed, stability and availability.
  • Proven at scale. Many large engineering organisations, Google among them, develop on a shared trunk with heavy automated testing and code review.

Challenges and When It's Hard

  • Weak test coverage. Without good automated tests, merging to trunk daily spreads breakage quickly.
  • Slow reviews or approvals. Heavyweight review processes, which DORA calls out as a common pitfall, push developers back toward long-lived branches.
  • Regulated environments. Change approval processes may need redesigning around automated evidence rather than manual sign-off per release.
  • Distributed open source. Projects with occasional outside contributors often rely on longer-lived forks and pull requests; trunk principles apply more loosely.
  • Flag sprawl. Feature flags need lifecycle management or they become a source of bugs.
  • Culture. Developers used to finishing a whole feature before sharing it need practice slicing work and showing incomplete (but switched-off) code.

How to Adopt Trunk Based Development

  1. Measure where you are: count active branches and how long they live, and track how often code reaches main.
  2. Strengthen CI first: fast builds, reliable tests, required checks on main, and a merge queue if conflicts are common.
  3. Set a branch lifetime target, such as "merged within two days", and make it visible.
  4. Introduce feature flags with a simple tool or library and a policy for removing them.
  5. Shrink pull requests: agree on size guidelines and fast review expectations, measured in hours.
  6. Retire the `develop` branch if you're coming from GitFlow; make main the integration point.
  7. Practise recovery: make rollback and fix-forward routine so mistakes are cheap. Our site reliability engineering guide covers the operational side.

FAQ

Is trunk based development better than GitFlow?

For teams that deploy continuously, usually yes: it integrates work sooner, avoids big merges and fits continuous delivery. GitFlow can still make sense for software released in versions with several supported releases at once.

Does trunk based development mean no branches?

No. Most teams use short-lived feature branches and pull requests that merge within a day or two, plus optional release branches cut from trunk. What it avoids is long-lived development branches.

How do you handle unfinished features?

With feature flags, branch by abstraction and keystone interfaces. Code merges to trunk switched off, so users don't see it until it's ready.

Can large teams use trunk based development?

Yes. It requires strong automated testing, fast CI, merge queues and disciplined, small changes, but many large organisations work this way.

How often should you merge to trunk?

At least once a day per developer, according to DORA's guidance. Many teams merge several times a day.

All articles

Read next

Language

EnglishEnglish · en TürkçeTurkish · tr DeutschGerman · de العربيةArabic · ar

Account

Enter your email. We’ll send you a sign-in link and a 6-digit code. No password needed.

Sign in

Theme

Language

Show our email address

To keep spam out of our inbox, please confirm your own email first. We will send you a 6-digit code.

We send codes only to these providers: gmail.com, googlemail.com, outlook.com, hotmail.com, live.com, msn.com, proton.me, protonmail.com, pm.me, icloud.com, me.com, mac.com, yahoo.com, aol.com, gmx.de, gmx.net, web.de, t-online.de, yandex.com, omniai.blog