Designing a Branch Strategy
This lesson compares trunk-based development, feature branches and release branches.
Learning outcomes
After completing this lesson, you will be able to:
- Explain the practices that make trunk-based development safe.
- Explain the risk of long-lived branches.
- Explain when release branches are justified.
- Choose a strategy from stated requirements.
Trunk-based development
In trunk-based development, all developers integrate small changes into a single branch, called main or trunk, at least once a day. Research from DORA associates this practice with high delivery performance, because integration problems appear at once, when they are small.
Three practices make it safe. Short-lived branches, lasting hours or a day or two, are used for review, or small teams commit directly. Automated tests run for every change, so main stays healthy. Feature flags hide unfinished work, which means that a half-built feature can be merged without being exposed to users. Without those practices, trunk-based development quickly breaks main.
What makes trunk-based development safe?
Feature branches
A feature branch holds the work for one change until it is ready, then merges through a pull request. It gives each change a place for isolated review and testing. Its main risk is duration. A feature branch that lasts for six weeks diverges from main, so the merge is large and risky, and nobody tests the combination of all in-flight work. In practice, the same pattern is safe when branches last a day or two, which is really GitHub Flow, and hazardous when they last for weeks.
Fork-based workflows extend this idea for open-source projects, or for contributors who should not have write access to the main repository. A contributor works in a personal copy, and submits a pull request back to the original repository.
Release branches
A release branch is created from main when a version is ready to stabilize, for example release/2.3. Only fixes go onto it, and new development continues on main. It is needed when a team must support released software that it cannot simply replace, such as installed desktop software, or a product where customers remain on different versions.
The direction in which fixes travel matters. Microsoft recommends the release flow approach, in which a fix is made first in main and then cherry-picked to the release branch. This guarantees that the fix cannot be lost in the next release. A team that fixes only the release branch must remember to bring the change back, and the defect may reappear.
A fix under release flow
Other named workflows
GitFlow uses long-lived main and develop branches, along with feature, release and hotfix branches. It suits scheduled releases of versioned products, but its number of branches slows integration, so it is often unsuitable for continuous delivery. On the exam, a team that struggles with merges and wants to deploy often should move away from it.
Environment branches, with one branch for each of test, staging and production, are a related pattern that causes drift, because code on each branch can differ. Modern practice is to build one artifact and promote it through environments, as a later lesson explains.
GitFlow and environment branches
Choosing a strategy
The following table summarizes how requirements point to a strategy. These strategies can be combined: a team might use trunk-based development on main and add release branches only for versions that need support.
| Situation | Recommended approach |
|---|---|
| Frequent deployments of a single web service | Trunk-based development or GitHub Flow |
| Long-running work that cannot be released yet | Trunk-based development with feature flags |
| Several supported versions in production | Add release branches, with fixes made on main first |
| Untrusted or external contributors | Fork-based pull requests |
| Painful merges from long-lived branches | Shorter branches and more frequent integration |
The following diagram compares sprint-long feature branches with the recommended short-lived branches.

Matching strategy to situation
Reducing merge pain
A team of 12 developers keeps a feature branch open for each sprint-long feature. Merges at the end of each sprint take two days, and defects often appear only after merging. The product is a single web application deployed to one environment. What should you recommend?
The team should move to short-lived branches or trunk-based development, integrating at least daily, and use feature flags so that incomplete work can reach main safely. Automated tests on each pull request keep main healthy. Adding a develop branch, as in GitFlow, would add another integration stage without addressing the long-lived branches. Release branches are not justified, as only one version is in production.
Under release flow, where is a fix made first?
Show answer
In main, and it is then cherry-picked to the release branch. This guarantees that the fix reaches future releases.
Exam Tips
Remember for the exam
- Trunk-based development: integrate at least daily, with feature flags and tests.
- A long-lived feature branch is the usual cause of painful merges.
- Release branches are justified by several supported versions.
- Make a fix in main first, then cherry-pick it to the release branch.
- GitFlow suits scheduled versioned releases more than continuous delivery.