Skip to main content

Command Palette

Search for a command to run...

Git Branching Strategies

Published
4 min read
Git Branching Strategies

Stop Building Skyscrapers on a Swamp: A Simple Guide to Git Branching Strategies

“A bad branching strategy is like trying to build a skyscraper on a swamp.”

If you have ever stared at a Git history that looks like a bowl of spaghetti, you know exactly what that quote means. Without a solid foundation, your code collapses.

In this guide, we’ll break down what a Branching Strategy is, why it is the backbone of modern DevOps, and how to implement a standard 5-environment flow that keeps your team sane and your software stable.

Image of DevOps lifecycle loop

What Is a Branching Strategy?

Simply put, a branching strategy is the "traffic laws" for your code. It is a set of rules your team follows to manage changes. It dictates how you create new features, how you fix bugs, and—most importantly—how that code moves from your laptop to the real world.

It isn’t just about using Git commands; it is a strategic approach that improves:

  • Velocity: How fast you can ship.

  • Quality: How few bugs reach users.

  • Collaboration: How well your team works without overriding each other's code.

The Cost of Chaos

Imagine a team without a strategy:

  • Everyone pushes code to the same place at the same time.

  • Testers don't have a safe place to test.

  • If production breaks, there is no "safe" version to roll back to.

This team spends 80% of their time fighting fires and only 20% building features.

Now, imagine a team with a strategy:

  • Developers work in isolated safety bubbles (Feature branches).

  • Testers have a stable environment (QA).

  • Production is locked down and secure.

  • Disaster Recovery (DR) is ready to go at a moment's notice.

This team sleeps well at night.


The Master Plan: Environments & Branches

In a mature DevOps setup, your Git branches should mirror your actual server environments. This ensures that what you see in the code is exactly what is running on the server.

Image of git branching strategy flowchart

Shutterstock

Here is the 5-stage lifecycle of code:

1. The Construction Zone: Development (Dev)

  • Branch: dev

  • Purpose: This is the messy kitchen. It’s where active development happens. Features are half-finished, and bugs are expected.

  • How it works: Developers merge their work here after peer review. Every push here triggers a deployment to the Dev server.

2. The Quality Gate: QA

  • Branch: qa

  • Purpose: This is where the testers take over. It’s a stable environment used to run manual and automated tests.

  • How it works: Once code in dev looks good, it is merged into qa.

    Bash

      git checkout qa
      git merge dev
      git push origin qa
    

3. The Dress Rehearsal: Pre-Production (PPD)

  • Branch: ppd

  • Purpose: This is a mirror of Production. It uses real configurations and simulates real traffic. It’s used for User Acceptance Testing (UAT) and load testing.

  • How it works: Only code that has survived QA makes it here. It is often "frozen" before a big release.

4. The Main Stage: Production (PROD)

  • Branch: main

  • Purpose: The Holy Grail. This is the live application your users see.

  • How it works: Changes never go directly here. Code only arrives here after passing QA and PPD. Releases are usually "tagged" (e.g., v1.0).

    Bash

      git checkout main
      git merge ppd
      git tag -a v2.3.0 -m "Release April 2025"
    

5. The Safety Net: Disaster Recovery (DR)

  • Branch: dr

  • Purpose: This simulates the worst-case scenario. If your main region goes down, this branch deploys your code to a backup site or secondary cloud region.

  • How it works: It mirrors main and is used for periodic disaster recovery drills.


Supporting Characters: Feature, Bugfix, and Hotfix

Aside from the main environment branches, you need temporary branches to do the actual work.

1. Feature Branches (feature/*)

Used for developing new cool stuff.

  • Source: Branches off dev

  • Destination: Merges back into dev

  • Example: feature/dark-mode

2. Bugfix Branches (bugfix/*)

Used for fixing non-critical issues found during testing.

  • Source: Branches off dev or qa

  • Destination: Merges back into dev or qa

3. Hotfix Branches (hotfix/*)

This is the emergency lane. Used when a critical bug hits Production and can't wait for the full cycle.

  • Source: Branches off main

  • Destination: Merges into main AND back-merges to dev, qa, ppd, and dr.

  • Image of git hotfix workflow diagram

Note on Hotfixes: It is critical to merge the fix back to all lower environments (Dev/QA). If you forget this, the bug will reappear in your next release!


Summary Cheat Sheet

If you are setting up your repo today, here is your quick reference guide:

Environment

Branch

Who Owns It?

Triggers Deployment?

Dev

dev

Developers

On Push

QA

qa

QA Team

On Merge

Pre-Prod

ppd

Team Leads

On Merge

Production

main

Release Manager

On Tag

Disaster Recovery

dr

Infra Team

On Merge from Main