Skip to content

Git Workflow — GitHub Flow, Git Flow, and Trunk-Based Compared

DodaTech 3 min read

In this tutorial, you'll learn about Git Workflow. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

What You'll Learn

Understand the most popular Git workflows — how they work day-to-day, the rules each enforces, and how to choose (and implement) one for your team.

Why It Matters

A well-defined workflow prevents "who changed what" confusion, ensures code review, and keeps deployments safe. The workflow IS your Process — it affects every developer every day.

Github Flow

The simplest and most popular workflow.

The Rules

  1. Anything in main is deployable
  2. Create a branch for every feature/fix
  3. Open a PR early for discussion
  4. Get code review before merging
  5. Deploy immediately after merge

Daily Routine

# Start a feature
git checkout -b feature/add-search main

# Work, work, work
git add .
git commit -m "Add search bar component"

# Push and open PR
git push -u origin feature/add-search

# On GitHub: open Pull Request → get review → merge
# After merge, deploy automatically

# Clean up local branch
git checkout main
git pull
git branch -d feature/add-search

Git Flow

More structured, designed for versioned releases.

Branches

main (production releases)
  └── develop (integration branch)
       ├── feature/* (new features)
       └── release/* (release preparation)
  └── hotfix/* (urgent production fixes)

Daily Routine

# Start a feature
git checkout -b feature/user-auth develop

# Work, test, commit
git add .
git commit -m "Add user authentication"

# Merge back to develop
git checkout develop
git merge feature/user-auth

# When it's release time:
git checkout -b release/1.5.0 develop
# Bump version, final fixes
git checkout main
git merge release/1.5.0
git tag v1.5.0
git checkout develop
git merge release/1.5.0

# Hotfix: from main
git checkout -b hotfix/1.5.1 main
# Fix the bug
git checkout main
git merge hotfix/1.5.1
git tag v1.5.1
git checkout develop
git merge hotfix/1.5.1

Trunk-Based Development

Everyone commits to main multiple times a day.

The Rules

  1. Branch off main, merge within hours (not days)
  2. Use feature flags to hide incomplete work
  3. No long-lived branches
  4. CI must pass before merge

Daily Routine

# Pull latest
git checkout main
git pull

# Create short-lived branch
git checkout -b add-sort-option

# Implement quickly (30 min to 2 hours)
echo "sort button" > sort.js
git add -A
git commit -m "Add sort button"
git push -u origin add-sort-option

# Open PR, get quick review, merge
# Feature is behind a feature flag until complete

Workflow Comparison

Aspect Github Flow Git Flow Trunk-Based
Learning curve Low High Medium
PR size Small-medium Varies Tiny
Release Process Deploy on merge Tagged releases Feature flags
Hotfix speed Fast Medium Fast
Git history Linear-ish Complex Very linear
CI requirements Fast checks Standard Must be fast
Best for Web apps, SaaS Libraries, mobile Teams with CI maturity

Choosing a Workflow

# Answer these questions:
# 1. Do you version releases?         → Git Flow
# 2. Do you deploy multiple times/day? → GitHub Flow or Trunk-Based
# 3. Is your test coverage > 80%?      → Trunk-Based (else GitHub Flow)
# 4. Do you have < 10 developers?      → Any (Trunk-Based easier)
# 5. Are you a solo dev?               → GitHub Flow

Common Workflow Mistakes

Mistake Fix
Long-lived feature branches Merge or rebase daily
No code review Enforce PR checks
Committing directly to main Branch protection rules
Not deleting merged branches Automate cleanup
Big bang merges Small, frequent integrations

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro