Trunk-based development (TBD) is a source control branching model that involves creating only one healthy branch, typically named trunk, main, or master. In this approach, developers all work on the same branch without creating any long-lived branches.

Note

TBD differs from other feature branching models, such as GitFlow, which may contain multiple long-lived feature branches.

Info

Google follows Trunk-Based Development and has ten of thousands of developers and QA automators working in a single monorepo trunk.

The main goal of TBD is to ensure that every developer contributes to the trunk branch by creating pull requests on a daily basis. This practice helps maintain the health of the trunk branch and avoids dealing with a large chunk of changes from a branch during review.

Image source: Git Flow vs. Trunk Based Development | Toptal®

Image source: How to Select a Git Branch Mode? - Alibaba Cloud Community

There are some caveats you need to be aware of before you and your team integrate TBD into your workflow:

  1. A small team can commit directly to the trunk branch, whereas a larger team may create short-lived branches and pull requests for team review and CI checks.
  2. The team can choose to create a release branch to enable deployment to production.
  3. If there is a feature that cannot be completed in a single commit or a short-lived branch, you should create feature flags to control the display or functionality of the feature.

References