Gitflow: Streamlined Branching and Release Management for Teams

From feature branches to hotfixes, Gitflow ensures that teams can build, test, and release software efficiently. This guide walks through the Gitflow model step by step, showing you how to structure your branches, handle releases, and manage urgent production issues.

AAriful Alam
August 23, 2025
GitVersion Control
Also published on:dev.tomedium
Image failed to load

Modern software teams rarely push code directly to the main branch. As projects grow, a clear branching strategy becomes essential to manage features, fixes, and releases while keeping production stable. Branching strategies minimize conflicts, streamline collaboration, and provide a structured workflow for teams of any size.

Gitflow, proposed by Vincent Driessen (A successful Git branching model), is one of the most widely adopted models. It defines a hierarchy of branches and merge policies that ensure smooth development, stable production releases, and a way to address urgent issues without disrupting ongoing work.

Core Branches in Gitflow

Gitflow defines five main branch types, each serving a distinct purpose:

  1. main (or master)
    • Represents production-ready code.
    • Each commit here corresponds to a stable release.
    • All merges into main should go through pull requests.
  2. develop
    • Integration branch for ongoing development.
    • All completed features are merged here via PRs.
  3. feature/*
    • For new features or tasks.
    • Branch from develop and merge back via PRs.
    • Example: feature/user-authentication.
  4. release/*
    • Prepares a new version release.
    • Only bug fixes, documentation updates, or minor tweaks are allowed.
    • Merge into both main (production) and develop via PRs.
    • Example: release/1.2.0.
  5. hotfix/*
    • For urgent production fixes.
    • Branch from main and merge back into both main and develop using PRs.
    • Example: hotfix/payment-bug.

Gitflow in Action

1. Creating a Feature Branch

Imagine implementing user authentication:

# Start from develop
git checkout develop

# Create feature branch
git checkout -b feature/user-authentication

Work on your feature and commit frequently. Once ready, push to the remote and open a pull request into develop. After code review:

# Merge PR

# Delete feature branch after merge
git branch -d feature/user-authentication
git push origin --delete feature/user-authentication

✅ Feature integrated into develop safely.


2. Preparing a Release

When development is stable and ready for v1.2.0:

# Branch from develop
git checkout develop
git checkout -b release/1.2.0
git push -u origin release/1.2.0
  • Perform final bug fixes, update version numbers, and tweak docs.
  • Open a PR to merge release/1.2.0 into main.
  • Tag the release after merge:
git checkout main
git tag -a v1.2.0 -m "Release 1.2.0"
git push origin v1.2.0
  • Merge release back into develop via PR to sync changes.
  • Delete the release branch after merging.

3. Handling Hotfixes

Suppose a critical production bug is discovered:

# Branch from main
git checkout main
git checkout -b hotfix/payment-bug
git push -u origin hotfix/payment-bug
  • Fix the issue and commit.
  • Open a PR to merge hotfix/payment-bug into main.
  • Tag the hotfix release:
git checkout main
git tag -a v1.2.1 -m "Hotfix: Payment bug fixed"
git push origin v1.2.1
  • Open a PR to merge hotfix into develop.
  • Delete the hotfix branch after merging.

Visualizing Gitflow

Visualizing Gitflow

  • Feature branches → merge into develop via PRs.
  • Release branches → merge into main via PRs, then back to develop.
  • Hotfix branches → merge into both main and develop via PRs.

Best Practices

  • Use descriptive names:
    • feature/<task-name>
    • release/<version>
    • hotfix/<issue>
  • Always use pull requests for merges.
  • Delete branches after merging.
  • Tag releases for traceability.
  • Automate release process using CI/CD pipelines.

Conclusion

Gitflow provides a structured, safe, and collaborative workflow for modern development teams. By isolating features, releases, and hotfixes, it ensures code stability while allowing parallel development. For teams that need speed over structure, a simpler workflow may suffice, but for enterprise-grade software, Gitflow remains a proven approach.

© 2025 Ariful Alam