100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
DevOps

Trunk-Based CI

IntermediateTechnique2.8K learners

Trunk-based CI is a source-control and continuous-integration practice in which developers integrate small, frequent changes directly into a single shared branch (the trunk) rather than working in long-lived feature branches.

Definition

Trunk-based CI is a source-control and continuous-integration practice in which developers integrate small, frequent changes directly into a single shared branch (the trunk) rather than working in long-lived feature branches.

Overview

Trunk-based development stands in contrast to workflows built around long-lived feature branches, where developers work in isolation for days or weeks before merging, and merges become increasingly painful the longer a branch diverges from the trunk. In trunk-based CI, developers commit small, incremental changes directly to the trunk (commonly `main`) at least once a day, and every commit runs through an automated continuous integration pipeline of builds and tests before it's considered safe. Because work is integrated continuously rather than in large batches, trunk-based CI relies heavily on feature toggles to keep unfinished functionality hidden from end users while its code still merges into the trunk, and it favors short-lived branches — if branches are used at all — that live for hours rather than weeks. This approach is one of the foundational practices identified by the DevOps Research and Assessment (DORA) program as correlating with high-performing software delivery teams, since it minimizes merge conflicts, keeps the trunk always close to a releasable state, and enables true continuous integration and continuous deployment rather than integration only at the end of a release cycle. Adopting trunk-based CI usually requires supporting practices beyond just a branching policy: a fast and reliable automated test suite so that every commit can be validated quickly, feature toggles to decouple merging from releasing, and a culture of small, reviewable pull requests. Teams moving from GitFlow or long-lived feature branches to trunk-based CI often find the biggest adjustment is disciplined use of feature flags and a willingness to ship partially complete work behind a disabled toggle rather than holding it back in a branch.

Key Concepts

  • Developers commit small changes directly to a single shared trunk branch frequently
  • Short-lived or no feature branches, typically merged within hours rather than weeks
  • Every commit triggers an automated build and test pipeline before being considered safe
  • Heavy reliance on feature toggles to hide incomplete functionality from users
  • Identified by DORA research as a practice correlated with elite software delivery performance
  • Keeps the trunk continuously close to a releasable, deployable state
  • Reduces merge conflict risk compared to long-lived branch workflows

Use Cases

Enabling true continuous integration and continuous deployment pipelines
Reducing merge conflicts and integration pain on fast-moving teams
Supporting rapid, incremental delivery of small, reviewable changes
Combining with feature toggles to ship partially built features safely
Improving deployment frequency and lead time metrics tracked by DORA
Simplifying release management by keeping the trunk always deployable

Frequently Asked Questions

From the Blog