What is Trunk-Based Development
Development in single branch
Trunk-Based Development is a development methodology where all developers work in a single main branch (trunk/main), making frequent small commits.
Key Principles
- All changes go directly to main/trunk
- Short-lived feature branches (1-2 days max)
- Frequent commits (several times a day)
- Continuous integration is mandatory
Benefits
- Minimized merge conflicts
- Fast feedback
- Simple commit history
- Accelerated CI/CD processes
- Reduced integration risk
Practices for Success
- Feature Flags — hiding incomplete features
- Trunk-based + Short-lived branches — branches for 1-2 days
- Continuous Code Review — constant code review
- Automated Testing — automated tests on every commit
Comparison with Git Flow
| Aspect | Trunk-Based | Git Flow | |--------|-------------|----------| | Branches | 1 main | Many long-lived | | Releases | Continuous | Scheduled | | Complexity | Low | High | | Conflicts | Rare | Frequent |
When to Use
- Experienced teams with good test coverage
- Projects with CI/CD
- When frequent releases are needed