Software Development

Trunk-Based Development: The Git Strategy Powering Elite Engineering Teams

How committing directly to main — and never looking back — can make your team ship faster, break less, and sleep better at night.

If you’ve ever spent a Friday afternoon untangling a months-old feature branch that’s developed a personality of its own and refuses to merge without drama — this article is for you. Trunk-Based Development (TBD) is the antidote to that pain, and it’s the version control strategy quietly underpinning some of the most productive engineering organizations in the world.

Let’s walk through what it actually is, why it works, and how you can start using it — without blowing up your codebase in the process.

1. What Is Trunk-Based Development?

Trunk-Based Development is a source control branching model where all developers integrate their work into a single shared branch — commonly called main or trunk — at least once per day. Rather than living on long-running feature branches for weeks, you make small, focused changes and merge them quickly.

The official reference and community hub for this approach lives at trunkbaseddevelopment.com, maintained by Paul Hammant, one of the earliest proponents of the technique.

“Trunk-Based Development is a key enabler of Continuous Integration and, by extension, Continuous Delivery.”— DORA State of DevOps Report

This matters because it directly addresses the root cause of most integration headaches: divergence. The longer branches live in isolation, the harder they are to merge. TBD solves this by keeping the codebase permanently close to shippable.

2. TBD vs. GitFlow: A Direct Comparison

GitFlow, introduced by Vincent Driessen in 2010, is the most popular alternative. It uses long-lived branches for features, releases, and hotfixes. It made sense for software with scheduled release cycles (desktop apps, mobile SDK releases), but it creates friction in teams that ship continuously.

DimensionTrunk-Based DevelopmentGitFlow
Branch lifespanHours to 1–2 daysDays to weeks
Integration frequencyMultiple times per dayEnd of feature cycle
Merge conflictsRare and smallFrequent and painful
CI/CD compatibilityNative fitRequires workarounds
Suitable forWeb apps, SaaS, microservicesDesktop software, SDKs with versioned releases
Risk per commitLow (small batches)High (large diffs)

GitFlow isn’t wrong — it’s just optimized for a different era. If you’re releasing a versioned library on a quarterly schedule, it still makes sense. If you’re deploying to production ten times a day, GitFlow is overhead you don’t need.

3. The Research Behind It

This isn’t just aesthetic preference. DORA (DevOps Research and Assessment) has been running the world’s largest study on software delivery performance since 2014. Their data, compiled annually in the State of DevOps reports, consistently shows that trunk-based development is one of the strongest technical predictors of elite delivery performance.

Deployment Frequency: TBD Teams vs. Non-TBD Teams

Mean Time to Restore (MTTR) by Branching Strategy

Elite performers — those who deploy multiple times per day and recover from incidents in under an hour — are overwhelmingly using trunk-based practices. Elite performers combine TBD with fast CI — the research doesn’t isolate TBD as sufficient on its own.

The correlation isn’t accidental. Small, frequent integrations mean smaller blast radii when something goes wrong.

4. The Mechanics: How It Actually Works Day-to-Day

In practice, there are two flavors of TBD, and which one you use depends on your team size:

Solo or Small Teams (under ~5 engineers)

Developers commit directly to main. There are no feature branches at all. Every commit goes straight to trunk, CI runs immediately, and the code is always deployable. This is the purest form.

Larger Teams: Short-Lived Feature Branches

Branches exist, but they have a hard lifespan — typically no more than one to two days. A developer picks up a task, creates a branch, makes a few focused commits, opens a pull request, gets a review, and merges. The key word is short.

Here’s what a healthy day looks like using this pattern. Assuming you have Git and a remote like GitHub or GitLab set up, these commands will work on any Mac, Linux, or Windows (with Git Bash) machine:

# Start your day — always pull latest from trunk first
git checkout main
git pull origin main

# Create a short-lived branch (name it after the ticket or task)
git checkout -b feat/add-user-avatar

# ... do your work, then commit in small logical chunks ...
git add .
git commit -m "feat: add avatar upload endpoint"

# Before pushing, rebase on the latest trunk to stay current
git fetch origin
git rebase origin/main

# Push and open a PR — merge same day
git push origin feat/add-user-avatar

That’s it. The branch never survives the working day. Tomorrow, you pull main again and start fresh.

5. Feature Flags: The Secret Weapon

One question that always comes up: “What if my feature isn’t ready to be seen by users yet?” This is where feature flags (also called feature toggles) become essential.

Feature flags let you merge incomplete code to trunk while keeping it hidden from users behind a runtime toggle. The code is deployed, but the feature is off. When you’re ready — you flip the switch without a new deployment.

ScenarioWithout Feature FlagsWith Feature Flags
Feature takes 2 weeks to buildBranch open for 2 weeks → merge hellMerge daily, flag keeps it hidden
Need to A/B testSeparate branches per variantControlled rollout via flag config
Rollback neededEmergency rollback deploymentToggle flag off in seconds

Popular tools for managing feature flags include LaunchDarklyUnleash (open source), and PostHog. For simpler needs, even environment variables work perfectly well.

6. What Needs to Be in Place First

TBD isn’t a magic wand you wave. It requires a few prerequisites to not become chaos:

PrerequisiteWhy It MattersWithout It
Fast, reliable CITests must run on every commit1Broken trunk nobody notices
Good test coverageConfidence to merge frequentlyMerging is a gamble, not a habit
Code review culturePRs reviewed same dayBranches stale waiting for review
Feature flagsDecouple deploy from releaseHalf-built features hit production
Team disciplineSmall commits, clear messagesTrunk becomes a dumping ground

If your CI pipeline takes 45 minutes to run, fix that before adopting TBD. The model only works when the feedback loop is tight. Martin Fowler’s canonical post on Continuous Integration covers the principles well if you want to go deeper on this side of things.

7. Common Objections (And Honest Answers)

“But my feature isn’t done yet.”

Feature flags handle this. Merge the code, hide the feature. The branch doesn’t need to stay open just because the product work isn’t finished.

“We’ll break main all the time.”

Less often than you think, because your commits are smaller and easier to review. And when main does break, the broken commit is trivial to find — it was three lines, not three thousand.

“We need long-lived release branches.”

If you’re doing continuous deployment, you don’t need release branches — main is always your release. If you have versioned releases (say, a mobile app), you can cut a release branch at the moment of release and backport fixes, rather than living on it for months.

8. What We’ve Learned

Trunk-Based Development is less a tool and more a discipline. We’ve seen that the core idea — commit small, integrate often, keep trunk healthy — directly reduces the friction that makes software teams slow. We walked through how it compares to GitFlow, what the DORA research actually says about its impact on deployment frequency and recovery time, and how feature flags solve the “unfinished work” problem that makes long-lived branches feel necessary. We also looked at the practical prerequisites: fast CI, test coverage, same-day code reviews, and a team culture that values small, clean commits over large, dramatic ones. None of this is complicated. The hard part is the habit, not the technique.

  1. CI build time under 10 minutes is non-negotiable at team sizes above ~15 engineers. At 30-minute builds and 50 engineers, the math produces ~5 trunk breaks per day and 45–90 minute feedback loops — both of which undermine TBD’s core guarantees. At scale, this means test parallelization, build caching, and incremental test selection (running only tests affected by a given diff). ↩︎

Eleftheria Drosopoulou

Eleftheria is an Experienced Business Analyst with a robust background in the computer software industry. Proficient in Computer Software Training, Digital Marketing, HTML Scripting, and Microsoft Office, they bring a wealth of technical skills to the table. Additionally, she has a love for writing articles on various tech subjects, showcasing a talent for translating complex concepts into accessible content.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

3 Comments
Oldest
Newest Most Voted
Mikhail Melnik
3 months ago

I would like to see really big team 50+ people working by tbd triggering ci on each commit, assuming each person make ~5 commits per day with build time ~30 minutes. How fast they fail with that approach?

Mikhail Melnik
2 months ago

Hey, Eleftheria. Thank for the answer. You totally brigthened up the topic I had in mind, I mean build time in correlation with team size and choosen branching model. And it’s nice addition to your article as this specific prerequisite is often lost when authors want to popularize TBD-approach.

Back to top button