Branching models
A branching model is the agreement a team makes about how code flows from a developer’s machine to production: which branches exist, how long they live and how changes get merged. The model shapes how often a team can release and how painful each release is.
The three most common models
Section titled “The three most common models”| GitFlow | GitHub Flow | Trunk-Based Development | |
|---|---|---|---|
| Main branches | main + develop |
main |
main (the trunk) |
| Work branches | feature/, release/, hotfix/ |
Short-lived feature branches | Very short-lived, or none |
| Releases | Versioned, planned | Every merge can go out | Many times a day |
| Works well for | Versioned products, several versions in support | Web apps and services with continuous deployment | High-performing teams with strong automation |
| Watch out for | Long-lived branches, painful merges, slow delivery | Needs good tests and reviews on every pull request | Needs feature flags and fast, reliable pipelines |
What matters more than the name
Section titled “What matters more than the name”Whatever the model, a few practices separate healthy repositories from risky ones:
- the default branch is protected: no direct pushes;
- every change goes through a reviewed pull request with a passing build;
- work branches are short-lived and follow a naming convention;
- release and environment branches are merged back, so fixes are not lost.
The model a team says it follows and the one its repositories show are often different, and the difference is where delivery problems hide.
Impact on delivery
Section titled “Impact on delivery”Long-lived branches mean bigger merges, more conflicts and less frequent releases. That is why shorter-lived branches are associated with better DORA metrics: faster lead time and higher deployment frequency.
In Leavory
Section titled “In Leavory”Branching detects the model each repository really follows, recommends one for your team and gives each repository a checklist of what to change first.