Gitflow Workflow
A structured branching model for managing releases.
Branch Types
| Branch | Purpose | Lifetime |
|---|---|---|
main | Production code | Permanent |
develop | Development integration | Permanent |
feature/* | New features | Temporary |
release/* | Release preparation | Temporary |
hotfix/* | Urgent fixes | Temporary |
The Model
main: o-----------o-------o
| | |
hotfix: | | h--h
| |
release: | r--r
| / \
develop: o--o---o------o---o
| /
feature: f---f---f
Practice Gitflow
Feature Branches
Start from develop:
git checkout develop
git checkout -b feature/new-feature
# ... work ...
git checkout develop
git merge feature/new-feature
git branch -d feature/new-feature
Release Branches
Prepare for release:
git checkout develop
git checkout -b release/v1.0.0
# ... final testing, version bump ...
git checkout main
git merge release/v1.0.0
git tag v1.0.0
git checkout develop
git merge release/v1.0.0
git branch -d release/v1.0.0
Hotfix Branches
Fix production issues:
git checkout main
git checkout -b hotfix/security-fix
# ... fix the issue ...
git checkout main
git merge hotfix/security-fix
git tag v1.0.1
git checkout develop
git merge hotfix/security-fix
git branch -d hotfix/security-fix
Gitflow Commands
Using git-flow extension:
# Initialize
git flow init
# Features
git flow feature start new-feature
git flow feature finish new-feature
# Releases
git flow release start v1.0.0
git flow release finish v1.0.0
# Hotfixes
git flow hotfix start fix-name
git flow hotfix finish fix-name
When to Use Gitflow
Good for:
- Scheduled release cycles
- Multiple versions in production
- Large teams with clear release process
Not ideal for:
- Continuous deployment
- Small teams
- Rapid iteration
Exercise: Set Up Develop Branch
Create the develop branch from main:

