Hand-on Demo – Release Branching for Continuous Delivery
The Release Branching model is useful when multiple versions of the software must be maintained simultaneously (e.g., active development on the next release while supporting an existing release). It balances structured development with Continuous Delivery (CD).
Release Branching Core Principles
mainBranch:Represents the latest production release.
Only updated via merges from
release/orhotfix/branches.
release/Branches:Temporary branches used to finalize and stabilize a release.
Allow bug fixes or polishing before merging into
main.
developBranch (Optional): Used for integrating features before creating a release branch.feature/Branches: For feature development, based ondevelop(ormainin simple setups).hotfix/Branches: For urgent fixes directly based onmain.
Scenario: Managing a Release with Release Branching
1. Initial Setup
Branches:
main: Production-ready code.release/: Used for finalizing releases.develop(Optional): Active development branch.
Tools:
Git for version control.
CI/CD pipeline to test and deploy code.
2. Workflow Steps
Step 1: Feature Development
Develop features using feature/ branches based on develop:
xxxxxxxxxx111# Create a feature branch from develop2git checkout develop3git checkout -b feature/add-login-page4
5# Make changes and commit6echo "<h1>Login Page</h1>" > login.html7git add login.html8git commit -m "Add login page structure"9
10# Push the branch and create a PR11git push origin feature/add-login-pageAfter the feature is reviewed and approved, merge it into develop:
xxxxxxxxxx31git checkout develop2git merge feature/add-login-page3git push origin developStep 2: Create a Release Branch
When develop is ready for release:
xxxxxxxxxx31# Create a release branch from develop2git checkout develop3git checkout -b release/v1.0.0Update version numbers or release-specific files:
xxxxxxxxxx31echo "v1.0.0" > version.txt2git add version.txt3git commit -m "Update version to v1.0.0"Push the release branch for testing:
xxxxxxxxxx11git push origin release/v1.0.0Step 3: Finalize the Release
CI/CD runs staging tests on the release branch.
Apply bug fixes directly to the release branch:
xxxxxxxxxx41echo "Fix issue #123" >> login.html2git add login.html3git commit -m "Fix issue #123 in release v1.0.0"4git push origin release/v1.0.0Step 4: Merge and Deploy
When the release is stable:
Merge the release branch into
main:xxxxxxxxxx31git checkout main2git merge release/v1.0.03git push origin mainTag the release:
xxxxxxxxxx21git tag -a v1.0.0 -m "Release v1.0.0"2git push origin v1.0.0Merge the release branch back into
develop(if applicable):xxxxxxxxxx31git checkout develop2git merge release/v1.0.03git push origin developDelete the release branch:
xxxxxxxxxx21git branch -d release/v1.0.02git push origin --delete release/v1.0.0
The CI/CD pipeline deploys the main branch to production automatically.
Step 5: Handling Hotfixes
For urgent production fixes:
Create a hotfix branch from
main:xxxxxxxxxx21git checkout main2git checkout -b hotfix/fix-login-bugFix the issue, commit, and push:
xxxxxxxxxx41echo "Fix login bug in production" >> login.html2git add login.html3git commit -m "Fix login bug"4git push origin hotfix/fix-login-bugMerge into
mainanddevelop:xxxxxxxxxx61git checkout main2git merge hotfix/fix-login-bug3git push origin main4git checkout develop5git merge hotfix/fix-login-bug6git push origin developTag and delete the hotfix branch:
xxxxxxxxxx41git tag -a v1.0.1 -m "Hotfix for login bug"2git push origin v1.0.13git branch -d hotfix/fix-login-bug4git push origin --delete hotfix/fix-login-bug
Git Commands Summary
xxxxxxxxxx371# Feature development2git checkout -b feature/add-login-page3git commit -m "Add login page structure"4git push origin feature/add-login-page5git checkout develop6git merge feature/add-login-page7git push origin develop8
9# Create a release branch10git checkout -b release/v1.0.011git commit -m "Update version to v1.0.0"12git push origin release/v1.0.013
14# Finalize release15git checkout main16git merge release/v1.0.017git tag -a v1.0.0 -m "Release v1.0.0"18git push origin main19git push origin v1.0.020git checkout develop21git merge release/v1.0.022git branch -d release/v1.0.023git push origin --delete release/v1.0.024
25# Hotfix26git checkout -b hotfix/fix-login-bug27git commit -m "Fix login bug"28git push origin hotfix/fix-login-bug29git checkout main30git merge hotfix/fix-login-bug31git tag -a v1.0.1 -m "Hotfix for login bug"32git push origin main33git push origin v1.0.134git checkout develop35git merge hotfix/fix-login-bug36git branch -d hotfix/fix-login-bug37git push origin --delete hotfix/fix-login-bugAdvantages of Release Branching for CD
Version Control: Allows simultaneous support for multiple software versions.
Stability: Finalizes the release in a dedicated branch, avoiding disruptions in
develop.Flexibility: Hotfix branches address urgent production issues efficiently.
Challenges
Slightly more complex than simpler models like GitHub Flow.
Requires disciplined merging and tagging processes to maintain branch hygiene.






















Leave a Reply