Release branch
A branch cut from main for one release, such as release/1.4: it only takes fixes, the release is tagged and deployed from it, and new features keep landing on main for the next release. Trunk-based teams make each fix on main and cherry-pick it over; Gitflow teams fix on the release branch and merge it back. It has a cost: every fix must reach both branches, and a release branch kept for a long time drifts away from main, so teams keep it short and delete it after the next release ships.
Cut release/1.4 and watch new work keep landing on main but not on the release. Then ship it: the v1.4.0 tag from release/1.4 goes to production.
Chips are commits, newest on the right.
Commits on main: 3 · on release/1.4: 0 · Production: v1.3.2
main has A, B and C, and features D and E are ready to merge. Production runs v1.3.2.
Say it in a prompt
Cut release/1.4 from main a few days before the release with git switch -c release/1.4 and push it, and keep merging new features to main as usual. Allow only bug fixes on release/1.4: make each fix on main first, copy it over with git cherry-pick -x, and run CI on release/1.4 too. Tag v1.4.0 from release/1.4 and deploy that tag to production, then delete the branch once 1.5 has shipped. Vague vs precise prompt
Vague prompt
make a branch for the release Typical resultCreates a release branch that lives for months and keeps taking new features, with main merged into it now and then. The two branches drift, every merge brings conflicts, and nobody is sure what production runs.
Precise prompt
Cut release/1.4 from main at the commit we want to ship and allow only bug fixes on it: make each fix on main first, then copy it with git cherry-pick -x. Tag v1.4.0 from release/1.4 and deploy that tag, keep merging features to main, and delete the branch after 1.5 ships. Typical resultProduction runs exactly what was cut, plus the fixes picked onto it, and work on main never waits for the release. Every fix still has to land on both branches, and the branch lives only until the next release, so it doesn't drift far from main.
Seen on
- Martin Fowler, Patterns for Managing Source Code Branches: The Release Branch pattern: a branch that only accepts commits that stabilize one version for release, while the main team keeps adding features to the mainline. It warns that branches drift apart and fixes must be copied back, or a regression follows.
- trunkbaseddevelopment.com, Branch for release: Release branches are cut just in time, a few days before a release, and developers don't commit to them. A bug is fixed on trunk first and cherry-picked to the release branch, and the branch is deleted some time after the release.
- Atlassian Git tutorials, Gitflow workflow: Once enough features are in, you fork a release branch; from then on no new features go in, only bug fixes and other release tasks. When it is ready it is merged into main and tagged, and merged back into develop; the page itself calls Gitflow a legacy workflow.
You might describe it as
- lock what goes out in 1.4 while main keeps moving
- a branch that only takes fixes for one release
- keep shipping 1.4 while 1.5 work goes on main
Not to be confused with
- Cherry-pick
A release branch is a separate line of commits for one release that only takes fixes; cherry-pick is the git command that copies one commit, often a fix made on main, onto it.