Skip to main content

Command Palette

Search for a command to run...

πŸ”€ Git Branching Strategies Explained

Updated
β€’4 min read
πŸ”€ Git Branching Strategies Explained

πŸš€ Introduction

When you're working on a software project - especially in a team - managing your code effectively is critical. Git and GitHub enable this through branching strategies, but as a beginner, you might be confused by terms like develop, feature, or hotfix, or unsure which strategy fits your project best.

In this post, I’ll break down three popular Git branching strategies - Git Flow, Feature Branch Workflow, and Forking Workflow - explain how they work, and help you choose the right one.


🌳 Branching Strategies Overview

1. Git Flow Workflow

A structured and full-featured strategy for managing larger projects with scheduled releases.

πŸ”‘ Main Branches:

  • master – Stable, production-ready code.

  • develop – Integrates features; staging area before production.

  • feature/* – Individual feature development branches.

  • release/* – Pre-release staging and polishing.

  • hotfix/* – Urgent fixes for production issues.

πŸ” Typical Flow:

master <β€”β€” hotfix
   ↑
release
   ↑
develop <β€”β€” feature

πŸ§ͺ Example:

  1. git checkout -b develop master

  2. git checkout -b feature/login develop

  3. Merge feature into develop β†’ create release/* β†’ merge into master and tag β†’ back-merge into develop

βœ… Best for: Large teams, scheduled/versioned releases.
❌ Complex for fast-paced or CI/CD-driven environments.


2. Feature Branch Workflow

This lightweight and popular strategy is often mistakenly called "GitHub Flow" - but it's officially known as Feature Branch Workflow. GitHub Flow is a variant of this, optimized for continuous delivery.

πŸ”‘ Main Branch:

  • main or master – Always production-ready

  • feature/* – Short-lived branches for individual changes

πŸ” Typical Flow:

main <β€”β€” feature/* (via Pull Request)

πŸ§ͺ Example:

  1. git checkout -b feature/signup main

  2. Commit and push changes

  3. Open a PR, get it reviewed, and merge into main

βœ… Best for: CI/CD, small to medium teams, rapid releases
❌ Lacks pre-production stages like testing or staging unless you set them up in your CI pipeline


3. Forking Workflow

Mostly used in open-source projects where contributors don't have direct write access to the main repository.

πŸ”‘ Key Concept:

  • Contributors fork the main repository

  • Work is done in their personal clone

  • Changes are submitted via Pull Request back to the original repo

πŸ” Typical Flow:

origin/main <β€”β€” Pull Request <β€”β€” forked-repo/feature

πŸ§ͺ Example:

  1. Fork the repo on GitHub

  2. git clone your fork

  3. git checkout -b fix/typo

  4. Push and open a PR to the original repo

βœ… Best for: Open-source and external collaborations
❌ Not ideal for internal team projects due to overhead


πŸ“˜ Real-World Example: To-Do App

Let’s walk through how each strategy could apply to a simple project like a To-Do App.

πŸ”Έ Using Git Flow:

  • Start from master, create develop

  • Each feature (e.g., "Dark Mode") gets a feature/dark-mode branch from develop

  • Once ready, create release/1.0.0 from develop

  • Merge release into master and develop, tag the release

  • If a crash is found in production, create hotfix/crash-fix from master

πŸ”Ή Using Feature Branch Workflow:

  • Start from main

  • Create a branch feature/dark-mode directly from main

  • Work and open a PR

  • After testing, merge to main and deploy

🌐 Using Forking Workflow:

  • Contributor forks the main repo

  • Creates a feature branch in their fork (e.g., feature/dark-mode)

  • Pushes and opens a PR to the main repo’s main branch


🧠 Summary Table

StrategyBest ForMain BranchesProsCons
Git FlowEnterprise apps, versioned releasesmaster, develop, feature/*, release/*, hotfix/*Structured, scalableComplex setup
Feature BranchStartups, CI/CD teamsmain, feature/*Simple, fastNo staging by default
Forking WorkflowOpen-source projectsForks, PRs to mainSecure, external contributionsSlower workflow

πŸ” Text-Based Diagrams

Git Flow:

*--------------------*-------------------> master
         \             \           
          \             *------------> hotfix/*
           \
            *-------------------------> release/*
             \
              *--*--*--*--*-----------> develop
                 \  \  \  \
                  \  \  \ *----------> feature/*
                   \  \  *-----------> feature/*
                    \  *-------------> feature/*

Feature Branch:

main
  |\
  | *--> feature/login
  | *--> feature/dark-mode
  | *--> feature/tags
  --> PR merge back to main

Forking:

original-repo/main
        ^
        |
  Pull Request
        |
  forked-repo/feature

βœ… Final Tips

  • Choose a strategy that matches your team’s workflow and delivery model.

  • Always pull latest changes before creating new branches.

  • Use clear, consistent branch naming (feature/login-page, hotfix/api-timeout).

  • Keep commits focused and meaningful.

  • Use tags for versioning (v1.0.0, v1.0.1).

With the right strategy, your team can work efficiently, reduce conflicts, and release with confidence.

5 views

More from this blog

Iresh's Blog

20 posts