Home/Blog/Git Branching Strategies: GitFlow, GitHub Flow, and Trunk-Based Development
Software Engineering

Git Branching Strategies: GitFlow, GitHub Flow, and Trunk-Based Development

Compare Git branching strategies including GitFlow, GitHub Flow, GitLab Flow, and trunk-based development. Learn which strategy fits your team size, release cadence, and workflow.

By Inventive HQ Team
Git Branching Strategies: GitFlow, GitHub Flow, and Trunk-Based Development

Choosing the right Git branching strategy can make or break your team's productivity. The wrong choice leads to merge conflicts, delayed releases, and frustrated developers. This guide compares the three most popular strategies—GitFlow, GitHub Flow, and trunk-based development—helping you choose the right approach for your team.

Branching Strategy Overview

┌─────────────────────────────────────────────────────────────────────────┐
│                    Branching Strategy Comparison                         │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                          │
│  GITFLOW                    GITHUB FLOW           TRUNK-BASED            │
│  ─────────────────────────────────────────────────────────────────────   │
│                                                                          │
│  main ─────●─────────────   main ─────●───────   main ─────●─────────   │
│            │                          │                    │             │
│  develop ──●──●──●──●────            ╱│╲                  ╱│╲            │
│               │     │              ╱  │  ╲              ╱  │  ╲          │
│  feature ────●     │           feat1  │  feat2    commit commit commit   │
│                    │                  │                    │             │
│  release ─────────●              deploy             deploy deploy        │
│                                                                          │
│  Complexity: High            Medium                Low                   │
│  Release: Scheduled          Continuous            Continuous            │
│  Team Size: Large            Small-Medium          Any (with discipline) │
│                                                                          │
└─────────────────────────────────────────────────────────────────────────┘

Strategy 1: GitFlow

GitFlow, created by Vincent Driessen in 2010, uses multiple long-lived branches to manage releases. It's designed for teams with scheduled release cycles.

Branch Structure

BranchPurposeLifetime
mainProduction code, tagged releasesPermanent
developIntegration branch for featuresPermanent
feature/*New feature developmentDays to weeks
release/*Release preparationDays
hotfix/*Emergency production fixesHours to days

GitFlow Workflow

┌─────────────────────────────────────────────────────────────────────────┐
│                         GitFlow Branch Model                             │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                          │
│  main     ●───────────────────────●──────────────────●──────────────    │
│           │                       │                  │                   │
│           │            ┌──────────┘     ┌────────────┘                   │
│           │            │                │                                │
│  hotfix   │            │     ●──●───────┘                                │
│           │            │                                                 │
│  release  │      ●─────●─────────────────●                               │
│           │     ╱                        │                               │
│  develop  ●────●──●──●──●────────────────●──●──●──●─────────────────    │
│                   │        │                  │                          │
│  feature          ●────────●                  ●──●──●                    │
│                                                                          │
│  Legend: ● = commit/merge point                                          │
│                                                                          │
└─────────────────────────────────────────────────────────────────────────┘

GitFlow Commands

# Initialize GitFlow (if using git-flow extension)
git flow init

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

# Finish a feature (merge to develop)
git checkout develop
git merge --no-ff feature/user-authentication
git branch -d feature/user-authentication

# Start a release
git checkout develop
git checkout -b release/v1.2.0

# Finish a release (merge to main and develop)
git checkout main
git merge --no-ff release/v1.2.0
git tag -a v1.2.0 -m "Release version 1.2.0"
git checkout develop
git merge --no-ff release/v1.2.0
git branch -d release/v1.2.0

# Hotfix
git checkout main
git checkout -b hotfix/security-patch
# ... fix the issue
git checkout main
git merge --no-ff hotfix/security-patch
git tag -a v1.2.1 -m "Security patch"
git checkout develop
git merge --no-ff hotfix/security-patch
git branch -d hotfix/security-patch

When to Use GitFlow

Good for:

  • Scheduled release cycles (monthly, quarterly)
  • Teams needing formal QA periods
  • Software with multiple supported versions
  • Compliance requirements needing release documentation
  • Teams already comfortable with Git

Not ideal for:

  • Continuous deployment
  • Small teams (< 5 developers)
  • Rapid iteration environments
  • Teams new to Git

Strategy 2: GitHub Flow

GitHub Flow is a simplified branching model designed for continuous deployment. Created by GitHub, it uses only main and feature branches.

Branch Structure

BranchPurposeLifetime
mainProduction-ready codePermanent
feature/*All development workHours to days

GitHub Flow Workflow

┌─────────────────────────────────────────────────────────────────────────┐
│                        GitHub Flow Model                                 │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                          │
│  main     ●────●────●────●────●────●────●────●────●────●───────────     │
│           │    │    │    │    │    │    │    │    │    │                 │
│           │    ▼    │    ▼    │    ▼    │    ▼    │    ▼                 │
│        deploy  │ deploy  │ deploy  │ deploy  │ deploy  │                 │
│                │         │         │         │         │                 │
│  feature/      ●─────────┘         │         │         │                 │
│  login                             │         │         │                 │
│                                    │         │         │                 │
│  feature/                          ●─────────┘         │                 │
│  dashboard                                             │                 │
│                                                        │                 │
│  feature/                                              ●─────────────    │
│  api-v2                                                (in progress)     │
│                                                                          │
│  Steps: 1. Branch → 2. Commit → 3. PR → 4. Review → 5. Merge → 6. Deploy │
│                                                                          │
└─────────────────────────────────────────────────────────────────────────┘

GitHub Flow Commands

# Create and switch to feature branch
git checkout main
git pull origin main
git checkout -b feature/add-user-dashboard

# Make changes and commit
git add .
git commit -m "feat(dashboard): add user statistics widget"

# Push branch and create PR
git push -u origin feature/add-user-dashboard
# Open PR on GitHub

# After PR approval and merge (on GitHub)
git checkout main
git pull origin main
git branch -d feature/add-user-dashboard

# Deploy happens automatically after merge to main

Pull Request Workflow

  1. Create branch from main
  2. Add commits with descriptive messages
  3. Open pull request describing changes
  4. Discuss and review with team
  5. Deploy from branch (optional, for testing)
  6. Merge after approval
  7. Deploy to production automatically

When to Use GitHub Flow

Good for:

  • Continuous deployment
  • Small to medium teams
  • Web applications and SaaS
  • Teams wanting simplicity
  • Rapid iteration cycles

Not ideal for:

  • Multiple supported versions
  • Formal release processes
  • Long feature development cycles

Strategy 3: Trunk-Based Development

Trunk-based development (TBD) is the most aggressive approach—all developers commit to a single main branch (the "trunk") with minimal or no branching.

Branch Structure

BranchPurposeLifetime
main (trunk)All developmentPermanent
release/*Optional release branchesDays (if used)
Short-lived branchesOptional, < 1 dayHours

Trunk-Based Workflow

┌─────────────────────────────────────────────────────────────────────────┐
│                    Trunk-Based Development                               │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                          │
│  PURE TRUNK-BASED (no branches):                                         │
│                                                                          │
│  main     ●──●──●──●──●──●──●──●──●──●──●──●──●──●──●──●───────────     │
│           │  │  │  │  │  │  │  │  │  │  │  │  │  │  │  │                 │
│           ▼  ▼  ▼  ▼  ▼  ▼  ▼  ▼  ▼  ▼  ▼  ▼  ▼  ▼  ▼  ▼                 │
│        deploy continuously or on every commit                            │
│                                                                          │
│  ─────────────────────────────────────────────────────────────────────   │
│                                                                          │
│  SCALED TRUNK-BASED (short-lived branches):                              │
│                                                                          │
│  main     ●──●──●──●──●──●──●──●──●──●──●──●───────────────────────     │
│              │     │     │     │     │                                   │
│              ●     ●     ●     ●     ●   (branches live < 1 day)         │
│                                                                          │
│  Key: All branches merge within 24 hours, CI runs on every commit        │
│                                                                          │
└─────────────────────────────────────────────────────────────────────────┘

Trunk-Based Commands

# Pull latest, make change, push (no branch)
git checkout main
git pull origin main

# Make your change
vim src/feature.js
git add .
git commit -m "feat: add caching to API calls"

# Push directly to main
git push origin main

# --- OR with short-lived branch ---

git checkout -b quick-fix
# Make change
git add .
git commit -m "fix: resolve null pointer"
git push -u origin quick-fix

# Merge same day via PR
# After merge:
git checkout main
git pull
git branch -d quick-fix

Requirements for Trunk-Based

Trunk-based development requires:

  • Excellent CI/CD: Tests must run fast and catch issues
  • Feature flags: Hide incomplete work in production
  • Small commits: Each commit should be deployable
  • Pair programming: Replaces code review for speed
  • Strong team discipline: Everyone must follow practices

Feature Flags Example

// Feature flag implementation
const features = {
  newDashboard: process.env.FEATURE_NEW_DASHBOARD === 'true',
  betaAPI: process.env.FEATURE_BETA_API === 'true',
};

// Usage in code
function renderDashboard() {
  if (features.newDashboard) {
    return <NewDashboard />;
  }
  return <LegacyDashboard />;
}

// Gradual rollout
const features = {
  newDashboard: userId % 100 < 10, // 10% of users
};

When to Use Trunk-Based

Good for:

  • High-performing teams with strong CI/CD
  • Continuous deployment environments
  • Teams practicing pair programming
  • Organizations like Google, Facebook, Microsoft

Not ideal for:

  • Teams without robust automated testing
  • Open source with external contributors
  • Teams unfamiliar with feature flags
  • Compliance-heavy environments

Strategy Comparison

Decision Matrix

FactorGitFlowGitHub FlowTrunk-Based
ComplexityHighLowLow
Release FrequencyScheduledContinuousContinuous
Best Team SizeLargeSmall-MediumAny
Learning CurveSteepGentleModerate
CI/CD RequirementOptionalImportantCritical
Feature FlagsOptionalHelpfulRequired
Merge ConflictsCommonOccasionalRare
Code ReviewPre-mergePre-mergeOften post-merge
Main StabilityVery stableStableMust be stable
Hotfix SpeedFastFastestFastest

Choosing Your Strategy

┌─────────────────────────────────────────────────────────────────────────┐
│                    Strategy Decision Tree                                │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                          │
│  Do you deploy continuously?                                             │
│  │                                                                       │
│  ├── NO → Do you have scheduled releases?                                │
│  │        │                                                              │
│  │        ├── YES → GitFlow                                              │
│  │        │                                                              │
│  │        └── NO → GitHub Flow (aim for CD)                              │
│  │                                                                       │
│  └── YES → Is your team highly disciplined with excellent CI?            │
│            │                                                             │
│            ├── YES → Trunk-Based Development                             │
│            │                                                             │
│            └── NO → GitHub Flow                                          │
│                                                                          │
└─────────────────────────────────────────────────────────────────────────┘

Branch Protection Rules

Regardless of strategy, protect your main branch:

# GitHub branch protection recommendations
main:
  required_pull_request_reviews:
    required_approving_review_count: 1
    dismiss_stale_reviews: true
  required_status_checks:
    strict: true
    contexts:
      - "ci/tests"
      - "ci/lint"
  enforce_admins: true
  required_linear_history: true  # For GitHub Flow/TBD
  allow_force_pushes: false
  allow_deletions: false

Migration Paths

GitFlow → GitHub Flow

  1. Prepare CI/CD for deploying from main
  2. Merge all active release branches
  3. Delete develop branch (merge to main first)
  4. Update branch protection rules
  5. Train team on simplified workflow
  6. Monitor for issues during transition

GitHub Flow → Trunk-Based

  1. Strengthen CI/CD pipeline (must be fast and reliable)
  2. Implement feature flag system
  3. Reduce PR review cycle time
  4. Start with short-lived branches (< 1 day)
  5. Gradually move to direct commits
  6. Consider pair programming for quality

Best Practices (All Strategies)

Branch Naming Conventions

# Feature branches
feature/PROJ-123-add-user-auth
feature/add-dashboard-widget

# Bug fixes
bugfix/PROJ-456-null-pointer
fix/login-redirect

# Hotfixes
hotfix/security-patch
hotfix/PROJ-789-critical-bug

# Releases (GitFlow)
release/v1.2.0
release/2026-q1

Commit Message Format

Follow Conventional Commits:

feat(auth): add OAuth2 login support
fix(api): resolve rate limiting issue
docs(readme): update installation instructions
refactor(core): simplify data processing pipeline
test(user): add integration tests for signup
chore(deps): update dependencies to latest versions

Keep Branches Short-Lived

StrategyMaximum Branch Age
Trunk-Based1 day
GitHub Flow3-5 days
GitFlow Feature2 weeks
GitFlow Release1 week

Conclusion

The best branching strategy depends on your team's size, release cadence, and deployment practices:

  • GitFlow: Large teams with scheduled releases
  • GitHub Flow: Most teams doing continuous deployment
  • Trunk-Based: High-performing teams with excellent CI/CD

Start simple with GitHub Flow, and only add complexity (GitFlow) or remove it (trunk-based) based on specific needs. Whatever strategy you choose, consistency across the team matters more than the specific approach.

For more Git guidance, see our complete Git & GitHub Guide.

Frequently Asked Questions

Find answers to common questions

GitHub Flow is ideal for small teams. It uses just main plus short-lived feature branches, with deployments happening from main after each merge. The simplicity reduces overhead while maintaining code quality through pull request reviews. Teams of 2-10 developers typically find GitHub Flow provides enough structure without complexity.

GitFlow uses multiple long-lived branches (main, develop, release, hotfix) designed for scheduled releases. GitHub Flow uses only main plus feature branches, deploying continuously. GitFlow suits teams with formal release cycles; GitHub Flow suits continuous deployment. GitHub Flow is simpler but GitFlow provides more release control.

Trunk-based development means all developers commit directly to the main branch (trunk) or use very short-lived feature branches (< 1 day). It requires excellent CI/CD, feature flags, and automated testing. High-performing teams like Google use it to achieve continuous integration and rapid deployment cycles.

Short-lived feature branches (1-3 days maximum) are strongly preferred. Long-lived branches lead to painful merges, integration issues, and delayed feedback. Keep branches small and focused on single features. If a feature takes longer, use feature flags to merge incomplete work safely into main.

In GitFlow, create a hotfix branch from main, fix the issue, then merge to both main and develop. In GitHub Flow, create a branch from main, fix, merge back to main, and deploy immediately. In trunk-based, commit the fix directly to main with proper testing. All strategies prioritize getting fixes to production quickly.

GitHub Flow and trunk-based development work best for continuous deployment. Both keep main in a deployable state and minimize the time between code completion and production. GitFlow's release branches add delay. For CD, merge to main should trigger automated deployment after tests pass.

When preparing a release, create a release branch from develop. Only bug fixes and release preparation (version bumps, documentation) go into this branch—no new features. Once ready, merge to main and tag the release, then merge back to develop. This isolates release stabilization from ongoing development.

Feature flags and feature branches solve different problems and work well together. Feature branches isolate development work; feature flags control runtime behavior. Use feature flags to safely merge incomplete features to main, enable A/B testing, or gradually roll out changes. They're complementary, not alternatives.

Use a consistent prefix convention like feature/, bugfix/, hotfix/, or release/. Include a ticket number if you use issue tracking: feature/PROJ-123-add-login. Keep names lowercase with hyphens. Examples: feature/user-authentication, bugfix/null-pointer-fix, hotfix/security-patch, release/v2.1.0.

First, ensure your CI/CD can deploy from main reliably. Merge or close all release branches. Set main as the default branch and enable branch protection. Train the team on the simpler workflow. You can transition gradually by treating develop as main initially, then eliminating it once comfortable with continuous deployment.

Engineering Excellence for Your Business

Our engineers build systems that scale. Clean architecture, comprehensive testing, and security-first development.