Trunk-based Development
A version control workflow where developers integrate small changes frequently into a single main branch.
Also known as: Trunk-based, Mainline Development
Category: Frameworks
Tags: software, version-control, workflows, devops, continuous-integration
Explanation
Trunk-based development is a version control workflow where all developers work on a single branch (the trunk, typically 'main' or 'master'), committing small changes frequently—often multiple times per day. Instead of long-lived feature branches, developers create very short-lived branches (hours, at most a day or two) or commit directly to the trunk.
The practice emphasizes continuous integration and small batch sizes. By integrating constantly, teams avoid the massive merge conflicts and integration problems that arise from long-lived branches. Each integration is small enough to review quickly and fix easily if it breaks something. This requires strong automated testing and CI/CD pipelines to catch problems immediately.
Trunk-based development often uses feature flags (toggles) to hide incomplete features in production. This allows incomplete code to exist in the trunk without affecting users—features are merged but not activated until ready. This decouples deployment from release, enabling true continuous deployment.
The approach requires discipline: comprehensive automated tests, rapid code review, backward-compatible changes, and feature flags for managing incomplete work. In return, it provides: simplified branching model, reduced merge conflicts, faster feedback, easier refactoring, and support for continuous deployment.
Trunk-based development contrasts with GitFlow's structured branches and long-lived features. It's optimized for web services and continuous deployment rather than scheduled releases. High-performing DevOps teams often use trunk-based development to maximize deployment frequency while maintaining stability.
Related Concepts
← Back to all concepts