my-git

Trunk-Based Development

English 中文

Trunk-Based Development emphasizes short branches, fast merges, and continuous trunk stability.

It is suited for teams with strong engineering discipline, fast CI feedback, and mature release automation.

Core Philosophy

Teams collaborate primarily around a single trunk branch, with very short lifecycles for development branches to avoid accumulating massive conflicts in long-lived branches.

Typical Process:

short-lived branch -> main -> CI -> deploy

Suitable Scenarios

Core Rules

Differences from Gitflow

Gitflow emphasizes multiple branch roles like develop, release, and hotfix, making it suitable for products with clear version release cadences.

Trunk-Based Development emphasizes trunk stability and frequent integration, making it suitable for service-oriented teams with high-frequency delivery.

Common Failure Modes

1. CI is Too Slow

Trunk development relies on fast feedback.

If CI frequently queues for tens of minutes, the team will start bypassing the process.

2. No Feature Flags

When large features cannot be completed at once, feature flags are needed to isolate unfinished capabilities.

Otherwise, half-finished features will appear in the trunk.

3. Branches are Still Long-Lived

If feature branches persist for weeks, you have essentially drifted away from the core practices of trunk-based development.

Enterprise Practice References

The core insight from Google Trunk-Based Development and Version Control Practices is that trunk development relies on a set of engineering capabilities: small changes, fast CI, code ownership, feature flags, and fast rollbacks.

When typical teams adopt it, don’t just chase “fewer branches”; build these supporting capabilities first.

Extended Reading