Trunk-based development 是一种分支策略,开发人员频繁地将小的变更集成到单一主分支(trunk)中,使用生命周期极短的分支(或直接提交)。它与高性能 CI/CD 紧密相关,因为它最大化了持续集成。
Trunk-based development 是什么
text
Developers commit small, frequent changes to a SINGLE shared branch (trunk/main):
→ very SHORT-LIVED branches (merged within hours or a day) — or commit directly
→ integrate continuously (multiple times a day) into trunk
→ trunk is kept always RELEASABLE (working, deployable)
→ vs long-lived feature branches that diverge for days/weeks before merging.
它为什么很好地支持 CI/CD
text
✓ MAXIMIZES continuous INTEGRATION — frequent small merges = the essence of CI
(catch integration issues immediately; tiny, easy-to-resolve conflicts)
✓ AVOIDS "merge hell" — no long-lived branches diverging → no big painful merges
✓ Small changes = lower risk, easier review, faster feedback
✓ Keeps trunk always deployable → enables continuous DELIVERY/deployment
→ Research (DORA) links trunk-based development to high delivery performance.
