Release branch
A release branch is a branch in version control that is cut from the main development line to stabilise one release. From the moment it is cut it takes bug fixes and release preparation only, while new feature work carries on in the main line. The released version is built from the code on that branch.
The longer version
The branch exists to hold a target still. Testing a release takes time, and while it runs the developers keep merging work meant for the release after it. Cutting a branch gives the testers a line of code that changes only when a fix for this release goes in, and gives everyone else a main line that never has to stop. The alternative is a code freeze on the main line, which buys the same stillness by making the whole team wait. A build taken from the branch for final testing is a release candidate, and the last of them is tagged with the version number and shipped. What may enter the branch is the rule that defines it: fixes for defects found in the release, version numbers and release metadata, and nothing that adds behaviour.
Git Flow, the model Vincent Driessen published in 2010 as "A successful Git branching model", gives the release branch a fixed place. It is branched from develop when develop almost reflects the desired state of the new release, and it is named with the prefix release-, as in release-1.2. Driessen writes that release branches "support preparation of a new production release", that bug fixes may be applied there, and that "Adding large new features here is strictly prohibited." When the branch is ready it is merged into master, that commit is tagged, and the branch is merged back into develop so that later releases keep the fixes. Then it is removed. In a note added in 2020, Driessen suggests a simpler workflow for teams doing continuous delivery and keeps the model for software that is explicitly versioned or supported in several versions at once.
Trunk-based development uses the branch more sparingly and in the opposite direction. Paul Hammant's Trunk-Based Development site describes release branches made from the trunk "on a just in time basis", a few days before a release, while developers keep committing to the trunk at full speed. The branch "should not receive continued development work". A bug is reproduced and fixed on the trunk first and then cherry-picked to the release branch, and not the other way round unless it cannot be reproduced on the trunk, because a fix made only on the branch can be forgotten and return as a regression weeks later. Release branches there are not merged back into the trunk, and are deleted once their release is no longer in production. The same site says teams with a very high release cadence do not use release branches at all and release from the trunk.
Microsoft's Release Flow sits between the two. Its teams batch deployments into timed releases, usually aligned with a three-week sprint, and at the end of each sprint create a branch such as releases/M129. Its own account is that release branches never merge back to the main branch, and that a fix always starts in main first and reaches the release branch as a cherry-pick through a pull request. The Azure Repos branching guidance gives the general rule: name the branch for its release, as in release/20, and lock it when that release stops being supported, because each active release branch is one more version of the code to maintain. Atlassian's Gitflow tutorial uses the same prefix, release/0.1.0, and now describes Gitflow itself as a legacy workflow that has lost ground to trunk-based ones. Whatever the model, a defect found during the release's testing should be reported against the branch build it was seen on, because the same bug on main may already be fixed or may never have existed there.
Common questions
What is a release branch?
A release branch is a line of code split off from the main development branch so that one release can be tested and fixed without new features arriving. Only fixes and release preparation are committed to it. The final build is made from the code on that branch and tagged with the release's version number.
When should a release branch be cut?
The branch is cut when everything intended for the release has been merged and stabilising is the work that remains. Git Flow puts that moment at the point where the develop branch almost reflects the desired state of the release. Trunk-based development cuts it on a just-in-time basis, a few days before the release.
What is allowed on a release branch?
Fixes for defects found in the release, the version number and other release metadata are allowed. New features are not, and Vincent Driessen's Git Flow post calls adding large ones strictly prohibited. Each exception weakens the reason for the branch, since every added change is something the release's testing has not yet covered.
How does Git Flow use a release branch differently from trunk-based development?
Git Flow fixes release defects on the release branch and then merges the branch into both master and develop. Trunk-based development, as described on Paul Hammant's Trunk-Based Development site, fixes them on the trunk and cherry-picks each fix to the release branch, and the branch is never merged back into the trunk.
Do teams that deploy continuously need a release branch?
A team that sends every passing change to production has nothing to stabilise separately, so it releases from the trunk. The Trunk-Based Development site says teams with a very high release cadence do not need release branches at all, and that a bug in production is then fixed on the trunk and released from it.
What is the difference between a feature branch and a release branch?
A feature branch holds one piece of new work until it is finished and merged, then disappears. A release branch is cut after the features are in and holds the whole release still while it is tested and fixed. Feature branches add behaviour, and a release branch exists to stop behaviour being added.
How should a release branch be named?
Name it after the release it stabilises, under a shared prefix. Atlassian's Gitflow tutorial uses release/0.1.0, Microsoft's Azure Repos guidance uses release/20, and Microsoft's own Release Flow names branches by sprint, as in releases/M129. The prefix lets tooling and branch permissions apply to every release branch at once.
Is a release branch the same as a staging branch?
The two are different things that are often connected. A release branch is a line of code being stabilised for one version. Staging is an environment, and some teams keep a branch whose contents are deployed there automatically. A release branch's builds are commonly deployed to staging for testing, which is where the confusion comes from.
Bug reports that arrive ready to triage.
Collect replay, console, network and browser context with the Free plan.