Branching strategies
Trunk-based development, GitHub flow and GitFlow, and when each fits.
A branching strategy is how a team uses branches to get changes into production. The trend is towards short-lived branches merged into main at least daily, because long-lived branches make painful merges and slow releases.
Feature flags make this possible: unfinished work can be merged switched off.
Cost. Free: it's a team agreement, enforced with branch rules.
Use it when
- a team argues about how to branch.
- merges regularly take days or break the build.
How it works
- Trunk-based
- Everyone merges small changes into main daily; releases come from main.
- GitHub flow
- Branch from main, open a pull request, review, merge, deploy.
- GitFlow
- Long-lived develop and release branches; suits boxed software with versions, rarely web services.
Options
- Trunk-based or GitHub flow
- For services deployed continuously.
- Release branches
- Only when you must support several versions at once.
Example. SS Kaiser moved from GitFlow to GitHub flow with feature flags: merges went from weekly battles to several small PRs a day.
Don't confuse it with
- Feature flags
- Hide unfinished work in main instead of keeping it on a branch.
- Environment branches
- A branch per environment drifts; promote the same build instead.
Words to know
- Trunk
- Another name for main.
- Long-lived branch
- A branch kept open for weeks; it drifts from main.
Where to look
- Repository rules
- Pull requests
- Feature flags
Practise it
- Commit, branch and merge with GitHow-to, Free
- Protect main and work through pull requestsHow-to, Free
- Feature flags with App ConfigurationHow-to, Free tier
Read it in the guide, next to the tasks and labs.
Open in DevOps, Hands On