Git Flow Branching Strategy
Git Flow is a branching model that defines a strict branching structure for production releases. It is popular in organizations with scheduled releases and long-lived release cycles.
Git Flow Branch Types
- main: Production-ready code only. Protected branch — only merge from release or hotfix branches
- develop: Integration branch where features are combined. Next release preparation
- feature/*: New features. Branch from develop, merge back to develop via PR
- release/*: Prep for production release. Branch from develop, merge to both main AND develop
- hotfix/*: Emergency bug fixes on production. Branch from main, merge to main AND develop
Git Flow in Practice
# Git Flow lifecycle example
# 1. Start a new feature
git checkout develop
git checkout -b feature/payment-gateway
# ... develop the feature ...
git add .
git commit -m "feat: add Stripe payment integration"
git commit -m "test: add payment gateway unit tests"
# 2. Merge feature back to develop
git checkout develop
git merge --no-ff feature/payment-gateway
git branch -d feature/payment-gateway
# 3. Create a release branch for v2.1.0
git checkout -b release/2.1.0
# Fix any last-minute bugs
git commit -m "fix: correct payment amount rounding"
# 4. Finish the release
git checkout main
git merge --no-ff release/2.1.0
git tag -a v2.1.0 -m "Release version 2.1.0"
git checkout develop
git merge --no-ff release/2.1.0
git branch -d release/2.1.0
# 5. Emergency hotfix
git checkout -b hotfix/payment-null-pointer
git commit -m "fix: handle null payment response"
git checkout main && git merge --no-ff hotfix/payment-null-pointer
git tag -a v2.1.1 -m "Hotfix 2.1.1"
git checkout develop && git merge --no-ff hotfix/payment-null-pointerQuick Quiz
Tip
Tip
Practice Git Flow Branching Strategy in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.
Trunk-based for CI/CD teams. Git Flow for versioned releases. GitHub Flow for small teams.
Practice Task
Note
Practice Task — (1) Write a working example of Git Flow Branching Strategy from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.
Common Mistake
Warning
A common mistake with Git Flow Branching Strategy is skipping edge case testing — empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready devops code.
Key Takeaways
- Git Flow is a branching model that defines a strict branching structure for production releases.
- main: Production-ready code only. Protected branch — only merge from release or hotfix branches
- develop: Integration branch where features are combined. Next release preparation
- feature/*: New features. Branch from develop, merge back to develop via PR