Git Flow Guide
1. What Is Git Flow?
A Git branching strategy designed for team collaboration
Provides structured management for feature development, bug fixes, and releases
Benefits:
- Minimizes confusion with dedicated, role-specific branches
- Ensures a stable and predictable release process
- Well-suited for team-based development workflows
2. Branch Types
Git Flow uses five primary branch types:
- main (master)
- Holds stable, production-ready code deployed to live environments
- Always maintained in a deployable state
- develop
- Integration branch for upcoming releases
- Central branch where all features and bug fixes are merged
- feature/
Branches for developing new features
Branched from
develop-> merged back intodeveloponce completeNaming examples:
feature/login-apifeature/ui-redesign
- release/
Branches for preparing a production release
Branched from
develop-> QA/testing and release bug fixes -> merged into bothmainanddevelopNaming example:
release/1.2.0
- hotfix/
Branches for urgent bug fixes in production
Branched from
main-> patched -> merged into bothmainanddevelopNaming example:
hotfix/1.2.1
3. Git Flow Branch Workflow
main -----------●------------------●------------------->
↑ ↑
│ │
release/1.2.0 hotfix/1.2.1
↑
develop ----●---●---●---●---●---●---●----------------->
↑ ↑
│ │
feature/login feature/payment4. Git Flow Step-by-Step Commands
(1) Developing a New Feature
git checkout develop
git checkout -b feature/feature-name
# After making code changes
git add .
git commit -m "feat: add feature description"
git checkout develop
git merge --no-ff feature/feature-name
git branch -d feature/feature-name(2) Preparing a Release
git checkout develop
git checkout -b release/1.2.0
# QA and release bug fixes
git commit -m "fix: resolve release QA bug"
git checkout main
git merge --no-ff release/1.2.0
git tag -a 1.2.0 -m "Release 1.2.0"
git checkout develop
git merge --no-ff release/1.2.0
git branch -d release/1.2.0(3) Urgent Production Hotfix
git checkout main
git checkout -b hotfix/1.2.1
# Fix the bug
git commit -m "fix: resolve urgent production bug"
git checkout main
git merge --no-ff hotfix/1.2.1
git tag -a 1.2.1 -m "Hotfix 1.2.1"
git checkout develop
git merge --no-ff hotfix/1.2.1
git branch -d hotfix/1.2.15. Commit Message Convention (Recommended: Angular Style)
feat: Add a new featurefix: Fix a bugdocs: Documentation changesstyle: Code style changes (semicolons, formatting, etc.)refactor: Code refactoring (no behavioral change)test: Adding or updating testschore: Build or tooling configuration changes
Examples:
feat(auth): implement login API
fix(ui): resolve button layout breakage on mobile screens6. Git Flow Collaboration Checklist
Start every new feature on a feature/ branch Never commit directly to develop; always integrate via merge Always manage deployments through a release/ branch Handle urgent production fixes immediately via a hotfix/ branch Use the --no-ff flag when merging to preserve branch history Follow the team's commit message convention