Trunk-Based Development: Integrate in Small Batches
Keep the integration branch healthy
Trunk-based development centers work around one shared integration branch, with frequent small integrations and short-lived branches where needed. It does not mean bypassing review or allowing broken builds. Compared with a week-long feature branch, small independently testable changes make feedback earlier and reduce the size of integration problems. GitHub Flow and trunk-based development can overlap; they are not mutually exclusive.
Separate integration from exposure
A feature flag is a runtime or configuration decision that controls whether a feature is exposed. It is not a Git branch. Scenario B uses a tiny Python program solely to illustrate a flag: gallery.txt is present in the committed tree, but a flag file contains off, so the program prints Gallery disabled. A later small change turns it on. Real systems need tests for both states, ownership, expiry and safe defaults; a flag is not an authorization boundary.
git show integrated-off:gallery.flaggit show enabled:gallery.flaggit diff --name-only integrated-off enabledTest small batches
The fixture actually executes the tiny program in both flag states and checks that the feature file exists even when disabled. The introduction of the disabled feature and its activation are separate commits. This is a local illustration, not a deployment or a production flag service. Review each batch and integrate only when its relevant checks pass. If a batch fails, stop and repair it or revert according to team policy.
python3 gallery.pygit log --oneline -3git status --shortChoose a branch lifetime
For a small documentation fix, aim for a reviewable change integrated promptly. A large feature can be split into compatible increments with the incomplete behavior hidden, provided the architecture permits it. Avoid defining an arbitrary lifetime as a universal rule; agree on cadence, CI capacity and review availability. Practice: if the gallery is not ready for users, integrate safe tested scaffolding with the flag off rather than leave a huge branch unreviewed.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Trunk-Based Development: Integrate in Small Batches — knowledge check
Reason about integration cadence, release scope and team policy.
What defines trunk-based development?
What does a feature flag control?
Can a disabled feature exist in Git history?
Which checks should a flag feature receive?
Does trunk-based development require bypassing reviews?