Git Flow: Examples & Real Use Cases
Git Flow is a branching model for Git, introduced by Vincent Driessen, designed to manage feature development, releases, and hotfixes in a robust and structured way.
Key Branches in Git Flow
- master: Always reflects production-ready state.
- develop: Integrates features; latest delivered development changes.
- feature/*: For new features; branched from
develop
. - release/*: Prepares for a new production release; branched from
develop
. - hotfix/*: Fixes urgent issues in production; branched from
master
.
Example Workflow
1. Starting a Feature
git checkout develop
git checkout -b feature/user-authentication
- Develop new feature (e.g., user authentication).
- Commit changes regularly.
- When done:
git checkout develop
git merge feature/user-authentication
git branch -d feature/user-authentication
2. Starting a Release
git checkout develop
git checkout -b release/1.0.0
- Finalize features, fix bugs, update version numbers.
- When stable:
git checkout master
git merge release/1.0.0
git tag -a 1.0.0
git checkout develop
git merge release/1.0.0
git branch -d release/1.0.0
3. Hotfixing Production
git checkout master
git checkout -b hotfix/1.0.1
- Fix critical production issue.
- When finished:
git checkout master
git merge hotfix/1.0.1
git tag -a 1.0.1
git checkout develop
git merge hotfix/1.0.1
git branch -d hotfix/1.0.1
Real Use Case
Scenario: Software Company Delivering SaaS
- Features: Each new feature (e.g., "Billing Integration") is developed in its own
feature/billing-integration
branch. - Release Preparation: Before deployment, all recent features are merged into a
release/2.5.0
branch for QA, bug fixing, and documentation updates. - Hotfixes: A critical security bug is discovered in production. A
hotfix/2.4.1
branch is created frommaster
, fixed, then merged back into bothmaster
anddevelop
.
Benefits:
- Clean separation of new development, stabilization, and urgent fixes.
- Parallel development without interfering with production code.
- Clear process for preparing and releasing software.
Summary
Git Flow is ideal for teams with a scheduled release cycle, multiple developers, and the need to support ongoing production hotfixes alongside new development. It brings structure and clarity to complex projects.