CurriculumTeam WorkflowsTrunk-Based Development
Lesson 2 of 540%
Advanced9 min+90 XP

Trunk-Based Development

Trunk-Based Development (TBD) is a workflow where all developers integrate to a single shared branch (the "trunk" or main) very frequently — at least once per day. Feature branches exist but are short-lived, merged within hours to days. Used by Google, Meta, and Netflix.

01.Core Principles of TBD

Integrate to trunk at least once a day. Feature branches live less than 2 days — long-lived branches accumulate conflict debt. Comprehensive automated test suite is non-negotiable — trunk must be deployable at every commit. Feature flags hide incomplete work in production. Small, focused commits over large batched ones. Code review happens fast because PRs are small.

Branch Visualization
featuremainHEAD
main
feature
HEAD

02.Feature Flags Enable TBD at Scale

Feature flags (feature toggles) let you merge incomplete code to trunk while keeping it invisible to users. The code is deployed but wrapped: if (flags.newDashboard) { /* new code */ }. This completely separates deployment (when code ships) from release (when users see it). Teams can merge daily even for multi-month features. Flags are managed via config, no code change needed to flip them.

Commit Timeline
a1b2c3d
init
b2c3d4e
feat
c3d4e5f
fix
d4e5f6a
HEAD

Commands

commands — click to reveal output
$
git checkout -b feat/x
Short-lived branch — target merge within 1-2 days
$
git pull --rebase origin main
Sync with trunk multiple times per day
$
git push origin feat/x
Push for PR review (fast — small changes = fast review)
$
# PR reviewed and merged same day
Speed is the goal — small PRs enable this
$
git checkout main && git pull
Start next task from latest trunk immediately
$
git branch -d feat/x
Delete feature branch immediately after merge
KNOWLEDGE CHECK

What is the defining characteristic of Trunk-Based Development?

Rate this lesson:
PreviousNext Lesson