🌿 Git Branching Strategy Explained

In real-world projects, we often need to develop new features without affecting the existing stable code. This is where branching strategy plays a vital role in organizing, developing, testing, and delivering code efficiently.
🧠Why Use Branching?
Let’s say you have a calculator app with basic functionality like addition and subtraction. Now, you want to add an advanced feature like percentage calculation. You don’t want this new change to break or interfere with the existing functionality. Here's how Git branches help manage this.
🌳 Branch Types
1. Main Branch (main
or master
)
Always contains production-ready code.
Must be kept up to date.
Only stable, tested features should be merged here.
2. Feature Branch
Created for adding new features (e.g.,
feature/percentage-function
).Branches off from
main
and merges back after development and testing.Keeps feature development isolated.
Example:
In Uber, the base product was just for cab rides.
When Uber wanted to add bike rides, they created a feature/uber-bikes
branch.
For intercity rides, they created another branch feature/uber-intercity
.
3. Release Branch
Used for final testing before delivering to customers.
Created from a feature branch or main.
Allows parallel development to continue while stabilizing a release.
Merges into both
main
anddevelop
(if using Git Flow model).
4. Hotfix Branch
Created when there’s a critical bug in production.
Branches from
main
, fixed quickly, and then merged into bothmain
andrelease
.Ensures immediate fixes don’t interrupt ongoing development.
🔄 Branching Workflow Summary
Branch | Purpose | Merges Into |
main | Production-ready code | From release , hotfix |
feature/* | New feature development | Into develop or main after testing |
release | Final testing & customer delivery | Into main |
hotfix/* | Quick fixes to live issues | Into main and release |
✅ Best Practices
Always test features in the feature branch before merging.
Keep
main
clean, stable, and deployable at all times.Use meaningful branch names (e.g.,
feature/percentage-calc
).Merge hotfixes into both
main
andrelease
to maintain consistency.
Subscribe to my newsletter
Read articles from Deepak Raj directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
