GitFlow
Updated: September 16, 2025Categories: Git
Printed from:
Complete GitFlow Cheatsheet
Table of Contents
- GitFlow Overview
- Installation & Setup
- Branch Structure
- GitFlow Initialization
- Feature Development
- Release Management
- Hotfix Management
- Support Branches
- GitFlow vs Manual Git Commands
- Best Practices
- Common Workflows
- Troubleshooting
- GitFlow Alternatives
GitFlow Overview
GitFlow is a branching model for Git that defines a strict branching model designed around project releases. It provides a robust framework for managing larger projects with scheduled releases.
Core Principles
- Two main branches:
main(production) anddevelop(integration) - Supporting branches:
feature,release, andhotfix - Parallel development: Multiple features can be developed simultaneously
- Release preparation: Dedicated branches for release preparation
- Emergency fixes: Quick hotfix deployment without disrupting development
GitFlow Diagram
main ──●────────●────────●──────── (production releases)
│ │ │
release │ ┌───●────●───┘ (release preparation)
│ │ │ │
develop ●────●───●────●────●─────── (integration branch)
│ │ │ │
feature │ └──●─────┘ │ (feature development)
│ │
hotfix └──────────────────●───┘ (emergency fixes)
Installation & Setup
Install GitFlow Extension
Using Package Managers
Bash
1234567891011121314151617# macOS (Homebrew)
brew install git-flow-avh
# Ubuntu/Debian
sudo apt-get install git-flow
# CentOS/RHEL/Fedora
sudo yum install gitflow
# or
sudo dnf install git-flow
# Windows (Chocolatey)
choco install gitflow-avh
# Windows (Scoop)
scoop install git-flow
Manual Installation
Bash
12345# Clone and install git-flow
git clone --recursive git://github.com/nvie/gitflow.git
cd gitflow
sudo make install
Verify Installation
Bash
123456# Check if git-flow is installed
git flow version
# Show available git-flow commands
git flow help
Branch Structure
Main Branches
-
main(ormaster): Production-ready code- Contains official release history
- Tagged with version numbers
- Always deployable
-
develop: Integration branch- Contains latest development changes
- Features are merged here first
- Base for new feature branches
Supporting Branches
Feature Branches
- Naming:
feature/feature-name - Purpose: Develop new features
- Lifetime: Until feature is complete
- Base:
develop - Merge to:
develop
Release Branches
- Naming:
release/version-number - Purpose: Prepare for production release
- Lifetime: Until release is deployed
- Base:
develop - Merge to:
mainanddevelop
Hotfix Branches
- Naming:
hotfix/hotfix-name - Purpose: Fix critical bugs in production
- Lifetime: Until fix is deployed
- Base:
main - Merge to:
mainanddevelop
Support Branches
- Naming:
support/version-number - Purpose: Support older versions
- Lifetime: Long-term maintenance
- Base:
main(specific tag) - Merge to: None (maintained separately)
GitFlow Initialization
Initialize GitFlow in Repository
Bash
123456789# Initialize GitFlow (interactive)
git flow init
# Initialize with default settings
git flow init -d
# Initialize with custom branch names
git flow init -f
Initialization Options
Bash
123456789# During initialization, you'll be prompted for:
# - Production branch name [main]
# - Development branch name [develop]
# - Feature branch prefix [feature/]
# - Release branch prefix [release/]
# - Hotfix branch prefix [hotfix/]
# - Support branch prefix [support/]
# - Version tag prefix []
Post-Initialization Setup
Bash
1234567# Push both branches to remote
git push -u origin main
git push -u origin develop
# Verify branch structure
git branch -a
Feature Development
Starting a Feature
Bash
1234567891011# Start new feature
git flow feature start <feature-name>
# Start feature from specific commit
git flow feature start <feature-name> <base>
# Examples
git flow feature start user-authentication
git flow feature start payment-integration
git flow feature start api-refactor
Working on Features
Bash
1234567891011121314# Switch to feature branch (if not already there)
git checkout feature/<feature-name>
# Regular development workflow
git add .
git commit -m "Add user registration endpoint"
git push origin feature/<feature-name>
# Publish feature branch (make available to others)
git flow feature publish <feature-name>
# Pull published feature
git flow feature pull origin <feature-name>
Finishing a Feature
Bash
123456789101112# Finish feature (merge to develop and delete branch)
git flow feature finish <feature-name>
# Finish feature keeping the branch
git flow feature finish -k <feature-name>
# Finish feature with rebase
git flow feature finish -r <feature-name>
# Force finish (even with unmerged changes)
git flow feature finish -F <feature-name>
Feature Branch Management
Bash
123456789# List all features
git flow feature list
# Track remote feature
git flow feature track <feature-name>
# Delete feature branch
git flow feature delete <feature-name>
Release Management
Starting a Release
Bash
1234567891011# Start new release from develop
git flow release start <version>
# Start release from specific commit
git flow release start <version> <base>
# Examples
git flow release start 1.2.0
git flow release start v2.0.0-beta
git flow release start 1.1.5
Working on Releases
Bash
1234567891011121314151617# Switch to release branch
git checkout release/<version>
# Make release-specific changes
# - Update version numbers
# - Update documentation
# - Fix last-minute bugs
# - Update changelog
# Example release preparation
echo "1.2.0" > VERSION
git add VERSION
git commit -m "Bump version to 1.2.0"
# Publish release branch
git flow release publish <version>
Finishing a Release
Bash
123456789101112131415161718# Finish release
git flow release finish <version>
# This will:
# 1. Merge release branch to main
# 2. Tag the release
# 3. Merge back to develop
# 4. Delete release branch
# Finish with custom tag message
git flow release finish -m "Release version 1.2.0" <version>
# Keep release branch after finishing
git flow release finish -k <version>
# Sign the release tag
git flow release finish -s <version>
Release Branch Management
Bash
123456789# List all releases
git flow release list
# Track remote release
git flow release track <version>
# Delete release branch
git flow release delete <version>
Hotfix Management
Starting a Hotfix
Bash
1234567891011# Start hotfix from main
git flow hotfix start <hotfix-name>
# Start hotfix from specific tag
git flow hotfix start <hotfix-name> <base-tag>
# Examples
git flow hotfix start security-patch
git flow hotfix start 1.2.1
git flow hotfix start critical-bug-fix
Working on Hotfixes
Bash
12345678910# Switch to hotfix branch
git checkout hotfix/<hotfix-name>
# Fix the critical issue
git add .
git commit -m "Fix critical security vulnerability"
# Publish hotfix if collaboration needed
git flow hotfix publish <hotfix-name>
Finishing a Hotfix
Bash
123456789101112131415# Finish hotfix
git flow hotfix finish <hotfix-name>
# This will:
# 1. Merge hotfix to main
# 2. Tag the hotfix
# 3. Merge back to develop
# 4. Delete hotfix branch
# Finish with custom tag message
git flow hotfix finish -m "Hotfix version 1.2.1" <hotfix-name>
# Sign the hotfix tag
git flow hotfix finish -s <hotfix-name>
Hotfix Branch Management
Bash
123456# List all hotfixes
git flow hotfix list
# Delete hotfix branch
git flow hotfix delete <hotfix-name>
Support Branches
Starting Support Branch
Bash
123456# Start support branch from main tag
git flow support start <version> <base-tag>
# Example
git flow support start 1.x 1.2.0
Working with Support Branches
Bash
12345678910111213# Support branches are for long-term maintenance
# They don't merge back to main or develop
# Used for maintaining older versions
# Make maintenance changes
git checkout support/<version>
git add .
git commit -m "Backport security fix to version 1.x"
# Create maintenance releases
git tag 1.2.1
git push origin 1.2.1
GitFlow vs Manual Git Commands
Feature Workflow Comparison
GitFlow Commands
Bash
1234git flow feature start user-auth
# ... development work ...
git flow feature finish user-auth
Equivalent Manual Git Commands
Bash
1234567891011121314# Start feature
git checkout develop
git pull origin develop
git checkout -b feature/user-auth
# ... development work ...
# Finish feature
git checkout develop
git pull origin develop
git merge --no-ff feature/user-auth
git branch -d feature/user-auth
git push origin develop
Release Workflow Comparison
GitFlow Commands
Bash
1234git flow release start 1.2.0
# ... release preparation ...
git flow release finish 1.2.0
Equivalent Manual Git Commands
Bash
1234567891011121314151617# Start release
git checkout develop
git pull origin develop
git checkout -b release/1.2.0
# ... release preparation ...
# Finish release
git checkout main
git pull origin main
git merge --no-ff release/1.2.0
git tag 1.2.0
git checkout develop
git merge --no-ff release/1.2.0
git branch -d release/1.2.0
git push origin main develop --tags
Best Practices
Branch Naming Conventions
Bash
1234567891011121314151617181920# Features
feature/user-authentication
feature/payment-integration
feature/api-v2
feature/JIRA-123-user-dashboard
# Releases
release/1.2.0
release/v2.0.0
release/2023.1
# Hotfixes
hotfix/security-patch
hotfix/1.2.1
hotfix/critical-login-bug
# Support
support/1.x
support/legacy-api
Commit Message Conventions
Bash
1234567891011121314# Feature commits
feat: add user authentication endpoint
feat(auth): implement JWT token validation
fix: resolve login redirect issue
# Release commits
chore: bump version to 1.2.0
docs: update changelog for v1.2.0
fix: last-minute bug fixes for release
# Hotfix commits
fix: critical security vulnerability in auth
hotfix: resolve payment processing error
Version Numbering
Bash
1234567891011# Semantic Versioning (MAJOR.MINOR.PATCH)
1.0.0 # Initial release
1.1.0 # New features (minor)
1.1.1 # Bug fixes (patch)
2.0.0 # Breaking changes (major)
# Pre-release versions
1.2.0-alpha.1
1.2.0-beta.2
1.2.0-rc.1
Team Collaboration Guidelines
Feature Development
Bash
1234567891011121314# Always start features from latest develop
git checkout develop
git pull origin develop
git flow feature start new-feature
# Regularly sync with develop
git checkout develop
git pull origin develop
git checkout feature/new-feature
git merge develop
# Publish features for collaboration
git flow feature publish new-feature
Code Review Process
Bash
12345678# For teams using pull requests
1. git flow feature start feature-name
2. # ... development work ...
3. git push origin feature/feature-name
4. # Create pull request to develop
5. # After approval, merge via PR
6. git flow feature delete feature-name
Common Workflows
Standard Feature Development
Bash
123456789101112131415161718192021# 1. Start feature
git flow feature start user-dashboard
# 2. Development work
git add .
git commit -m "feat: add user dashboard layout"
git commit -m "feat: integrate dashboard API"
git commit -m "test: add dashboard component tests"
# 3. Sync with develop (if needed)
git checkout develop
git pull origin develop
git checkout feature/user-dashboard
git merge develop
# 4. Finish feature
git flow feature finish user-dashboard
# 5. Push develop
git push origin develop
Release Process
Bash
123456789101112131415161718192021# 1. Start release
git flow release start 1.3.0
# 2. Release preparation
echo "1.3.0" > VERSION
git add VERSION
git commit -m "chore: bump version to 1.3.0"
# Update changelog
git add CHANGELOG.md
git commit -m "docs: update changelog for v1.3.0"
# Final testing and bug fixes
git commit -m "fix: resolve edge case in user validation"
# 3. Finish release
git flow release finish 1.3.0
# 4. Push everything
git push origin main develop --tags
Emergency Hotfix
Bash
123456789101112131415# 1. Start hotfix
git flow hotfix start 1.3.1
# 2. Fix the issue
git add .
git commit -m "fix: resolve critical payment processing bug"
# 3. Finish hotfix
git flow hotfix finish 1.3.1
# 4. Push everything
git push origin main develop --tags
# 5. Deploy hotfix immediately
Long-running Feature Branch
Bash
1234567891011121314151617181920212223242526# 1. Start feature
git flow feature start complex-feature
# 2. Regular development with syncing
while [ development_ongoing ]; do
# ... development work ...
git add .
git commit -m "progress on complex feature"
# Regular sync with develop
git checkout develop
git pull origin develop
git checkout feature/complex-feature
git merge develop
# Push progress
git push origin feature/complex-feature
done
# 3. Final sync and finish
git checkout develop
git pull origin develop
git checkout feature/complex-feature
git merge develop
git flow feature finish complex-feature
Troubleshooting
Common Issues and Solutions
GitFlow Not Initialized
Bash
1234# Error: Not a gitflow-enabled repo yet
# Solution: Initialize GitFlow
git flow init
Branch Already Exists
Bash
123456# Error: Branch 'feature/feature-name' already exists
# Solutions:
git flow feature checkout feature-name # Switch to existing
git branch -D feature/feature-name # Delete and recreate
git flow feature delete feature-name # Use GitFlow delete
Merge Conflicts During Finish
Bash
1234567# Error: Merge conflicts when finishing
# Solution:
git status # Check conflicts
# Resolve conflicts in editor
git add . # Stage resolved files
git flow feature finish feature-name # Continue finishing
Remote Tracking Issues
Bash
12345# Error: No tracking information
# Solutions:
git flow feature publish feature-name # Publish feature
git push -u origin feature/feature-name # Set upstream manually
Accidentally Started Wrong Branch Type
Bash
12345# Started feature instead of hotfix
git checkout main # Switch to correct base
git branch -m feature/fix hotfix/fix # Rename branch
git flow hotfix list # Verify it appears
Recovery Commands
Bash
1234567891011121314151617# Abort feature finish
git merge --abort
git checkout feature/feature-name
# Recreate deleted branch
git branch feature/feature-name commit-hash
git flow feature list
# Fix broken GitFlow config
git config --unset gitflow.branch.main
git config --unset gitflow.branch.develop
git flow init -f
# Clean up stale branches
git remote prune origin
git branch -d $(git branch --merged | grep -v main | grep -v develop)
Debugging GitFlow
Bash
1234567891011# Check GitFlow configuration
git config --get-regexp gitflow
# Verify branch structure
git branch -a
git log --oneline --graph --all
# Check remote configuration
git remote -v
git remote show origin
GitFlow Alternatives
GitHub Flow
Bash
12345678# Simpler workflow for continuous deployment
# Only main branch + feature branches
git checkout main
git checkout -b feature/new-feature
# ... development ...
# Pull request to main
# Deploy from main
GitLab Flow
Bash
12345678# Environment-based branching
# main -> pre-production -> production
git checkout main
git checkout -b feature/new-feature
# Merge to main via MR
# Merge main to pre-production
# Merge pre-production to production
OneFlow
Bash
1234567# GitFlow simplified
# main branch + feature/release/hotfix branches
# No develop branch
git checkout main
git checkout -b feature/new-feature
# Merge directly to main
Configuration Files
.gitflow Configuration
ini
1234567891011121314[gitflow "branch"]
master = main
develop = develop
[gitflow "prefix"]
feature = feature/
release = release/
hotfix = hotfix/
support = support/
versiontag = v
[gitflow "path"]
hooks = .git/hooks
Shell Aliases for GitFlow
Bash
123456789101112# Add to ~/.bashrc or ~/.zshrc
alias gf='git flow'
alias gff='git flow feature'
alias gffs='git flow feature start'
alias gfff='git flow feature finish'
alias gfr='git flow release'
alias gfrs='git flow release start'
alias gfrf='git flow release finish'
alias gfh='git flow hotfix'
alias gfhs='git flow hotfix start'
alias gfhf='git flow hotfix finish'
Quick Reference
Daily Commands
Bash
12345678910111213# Feature development
git flow feature start <name> # Start feature
git flow feature finish <name> # Finish feature
git flow feature list # List features
# Release management
git flow release start <version> # Start release
git flow release finish <version> # Finish release
# Hotfix management
git flow hotfix start <name> # Start hotfix
git flow hotfix finish <name> # Finish hotfix
Branch Overview
Bash
1234567891011# Check current status
git status
git branch -a
git log --oneline --graph --all -10
# Sync with remote
git checkout develop
git pull origin develop
git checkout main
git pull origin main
Remember: GitFlow is a branching model, not a replacement for Git fundamentals. Understanding basic Git commands is essential for troubleshooting and advanced operations.
Continue Learning
Discover more cheatsheets to boost your productivity