Understanding Gitflow: A Practical Guide

Understanding Gitflow: A Practical Guide
Gitflow

In software development, managing code efficiently is critical — especially when multiple developers collaborate on the same project.
One popular strategy for managing code in Git is Gitflow.
In this post, we'll break down Gitflow, walk through a simple example, and touch on how modern practices are evolving beyond it.


What is Gitflow?

Gitflow is a branching model for Git designed to organize work around different types of changes: new features, hotfixes, releases, and production-ready code.
It separates development work from production code using clearly defined branches.

The main goals of Gitflow are:

  • Clear separation between ongoing development and production code
  • Structured handling of hotfixes, features, and releases
  • Gatekeeping (reviews and approvals) before code reaches production

Typical branches in Gitflow:

  • main (or master) — production-ready code
  • develop — ongoing development
  • feature/* — new features under development
  • release/* — preparing a version for production
  • hotfix/* — urgent fixes to production

Gitflow: Simple Example

Let's walk through a real-world example:

Day 1

  • Project starts.
  • Code is deployed from the main branch.
git checkout main
git checkout -b develop

Development happens on develop, not on main.


Day 2

  • A critical bug is found in production.
  • Create a hotfix branch off main:
git checkout main
git checkout -b hotfix/critical-bug
`# fix the bug`
git commit -am "Fix critical bug"
git checkout main
git merge hotfix/critical-bug
git checkout develop
git merge hotfix/critical-bug
git branch -d hotfix/critical-bug

Hotfix is merged into both main and develop.


Day 3

  • Work begins on new features.

Each feature gets its own branch:

git checkout develop
git checkout -b feature/user-authentication

When a feature is complete:

git checkout develop
git merge feature/user-authentication
git branch -d feature/user-authentication

Day 4

  • Time for a release.
  • Create a release branch from develop:
git checkout develop
git checkout -b release/1.0.0
# polish, final fixes
git commit -am "Prepare release 1.0.0"
git checkout main
git merge release/1.0.0
git checkout develop
git merge release/1.0.0
git branch -d release/1.0.0

After merging into main, deploy to production.


Challenges with Gitflow

Although Gitflow was a breakthrough for structured team collaboration, it has some drawbacks:

  • Slow merging: Many manual steps for merging, approvals, and releases.
  • Long-lived branches: Features and hotfixes can conflict if branches stay alive too long.
  • High ceremony: Too many required steps slow down fast iterations.
  • Hotfix overwrite risk: A hotfix applied to main might be overwritten later if not merged properly into develop.

Modern Alternatives: CI/CD and "Shift Left"

As DevOps and DevSecOps practices evolved, the industry moved toward:

  • Continuous Integration/Continuous Deployment (CI/CD): Smaller, faster, automated changes.
  • Shift Left Testing: Testing earlier and more often, catching issues before release.

This led to simplified branching strategies — for example, using just main + short-lived feature branches, or trunk-based development, avoiding long-lived develop/release branches altogether.


Conclusion

Gitflow is a powerful and disciplined branching model that still fits many workflows — especially those with formal release cycles or enterprise processes.
However, modern teams practicing CI/CD often prefer simpler branching for faster delivery.

Understanding Gitflow is essential for any DevOps engineer, even if your team evolves toward faster and lighter Git strategies over time.

Read more