Release Branch in Gitflow: Definition and Usage
gitflow, a release branch is a temporary branch created from develop to prepare a new production release. It allows final testing, bug fixes, and versioning before merging into main and develop branches.How It Works
Think of a release branch as a staging area where you polish your product before showing it to customers. When your development work on the develop branch is ready for release, you create a release branch. This branch lets you fix small bugs, update documentation, and prepare version numbers without disturbing ongoing development.
Once everything is ready and tested on the release branch, you merge it into the main branch to mark the official release. You also merge it back into develop to keep new fixes synchronized. After merging, the release branch is deleted because its job is done.
Example
This example shows how to create a release branch, make a fix, and finish the release in gitflow.
git checkout develop # Create a release branch named 'release-1.0.0' git checkout -b release-1.0.0 # Fix a bug or update version # (edit files here) # Commit the fix git add . git commit -m "Fix bug and update version for release 1.0.0" # Merge release branch into main (production) git checkout main git merge --no-ff release-1.0.0 # Tag the release git tag -a v1.0.0 -m "Release version 1.0.0" # Merge release branch back into develop git checkout develop git merge --no-ff release-1.0.0 # Delete the release branch git branch -d release-1.0.0
When to Use
Use a release branch when your project is ready for a new version but needs final polishing before going live. It is helpful when multiple developers continue working on new features in develop while you prepare the release separately.
Real-world use cases include:
- Final bug fixes and testing before a product launch
- Updating documentation or version numbers without blocking new feature work
- Coordinating releases in teams where development and release cycles overlap
Key Points
- A
release branchis created fromdevelopto prepare a release. - It allows bug fixes and version updates without affecting ongoing development.
- After release, it merges into
mainanddevelop, then is deleted. - Helps teams manage releases and development in parallel.