Trunk-Based Development
What You'll Learn
You'll learn a branching strategy where developers commit directly to the main branch (the "trunk") with minimal or very short-lived branches, enabling continuous integration.
The Core Idea
Trunk-Based Development (TBD) is a branching strategy where everyone works on a single main branch—the "trunk." Instead of creating long-lived feature branches that exist for days or weeks, developers either commit directly to the trunk or create branches that last only a few hours before merging.
Think of it like a busy highway: rather than building separate side roads for every journey (long-lived branches), everyone uses the main highway and occasionally pulls off for quick pit stops (very short branches). This keeps traffic flowing and prevents massive traffic jams when trying to merge back.
Key Characteristics
Short-Lived Branches: If branches exist at all, they live for hours, not days. You might create a branch in the morning and merge it by lunch.
Frequent Integration: Developers integrate their code into the trunk multiple times per day. This means everyone always sees the latest changes from the team.
Feature Flags: Since incomplete features get merged into trunk, teams use feature flags (toggles) to hide work-in-progress from users. The code is there, but turned "off" until ready.
Small Commits: Instead of one giant commit with a complete feature, you make many tiny commits that each move the code forward safely.
Why It Matters
TBD reduces merge conflicts because no one's code drifts far from the trunk. It forces discipline: you can't let broken code sit in trunk, so testing and quality must be rigorous. It enables true continuous integration.
Key Takeaway: Trunk-Based Development keeps everyone working on one main branch with very short-lived feature branches, using feature flags to hide incomplete work and emphasizing frequent, small integrations.