Git Workflow Strategies: Trunk-Based vs GitFlow in 2025

Trunk-based development vs GitFlow: which git workflow fits your team? Learn the tradeoffs, CI/CD requirements, feature flag integration, and practical...

Y
Yash Pritwani
12 min read

The Git Workflow War

The debate between trunk-based development and GitFlow has been going on for years. In 2025, the industry has largely settled on trunk-based development for high-performing teams, but GitFlow still has valid use cases.

CodeBuildTestDeployLiveContinuous Integration / Continuous Deployment Pipeline

A typical CI/CD pipeline: code flows through build, test, and deploy stages automatically.

GitFlow: The Feature Branch Model

GitFlow uses long-lived branches for features, releases, and hotfixes:

main ──────────────────────────────────────────────────────────
  \                    /          \              /
   develop ──────────────────────────────────────
     \         /   \         /
      feature/A     feature/B
# Start a feature
git checkout develop
git checkout -b feature/user-dashboard

# Work on feature (days/weeks)
git commit -m "Add dashboard layout"
git commit -m "Add chart components"
git commit -m "Add API integration"

# Merge back to develop
git checkout develop
git merge --no-ff feature/user-dashboard
git branch -d feature/user-dashboard

# Create a release
git checkout develop
git checkout -b release/2.1.0
# Bug fixes only on release branch
git commit -m "Fix dashboard loading state"

# Merge release to main and develop
git checkout main
git merge --no-ff release/2.1.0
git tag v2.1.0
git checkout develop
git merge --no-ff release/2.1.0

GitFlow advantages:

  • Clear separation between in-progress and released code
  • Multiple versions can be maintained simultaneously
  • Release candidates can be stabilized in isolation
  • Well-suited for software with versioned releases (mobile apps, libraries, on-premise)

GitFlow problems:

Get more insights on DevOps

Join 2,000+ engineers who get our weekly deep-dives. No spam, unsubscribe anytime.

  • Merge conflicts accumulate on long-lived branches
  • Integration is delayed (find bugs late)
  • Release branches add process overhead
  • Branch management becomes complex with many features
  • Slows down deployment frequency

Trunk-Based Development: The Fast Lane

Trunk-based development has everyone committing to a single branch (main/trunk) with short-lived feature branches (max 1-2 days):

main ──●──●──●──●──●──●──●──●──●──●──●──●──────
       |     |  |        |  |        |
       └─●──●┘  └──●──●──┘  └──●────┘
       (hours)    (1 day)    (hours)
# Start work (branch lives < 24 hours)
git checkout main
git pull
git checkout -b yash/add-search-filter

# Small, focused commits
git commit -m "Add search input component"
git commit -m "Add filter logic to product grid"

# Push and create PR
git push -u origin yash/add-search-filter
# Create PR, get review, merge same day

# On merge, CI/CD deploys to production automatically

Trunk-based advantages:

  • Continuous integration (find bugs immediately)
  • Smaller PRs (easier to review, faster to merge)
  • No merge hell (conflicts are small and frequent)
  • Deploy multiple times per day
  • Forces modular, decoupled code

Trunk-based requirements:

  • Strong CI/CD pipeline (automated tests must be fast)
  • Feature flags (to deploy unfinished code safely)
  • Code review culture (small PRs reviewed quickly)
  • Good test coverage (confidence to merge to main)

Feature Flags Enable Trunk-Based

The key enabler for trunk-based development is feature flags. You can merge incomplete features to main without exposing them to users:

// Merge to main with flag off
if (featureFlags.isEnabled('new-checkout', user)) {
  return <NewCheckoutFlow />;
} else {
  return <LegacyCheckoutFlow />;
}

Deployment flow:

  1. Merge code to main (flag off)
  2. Deploy to production
  3. Enable flag for internal team
  4. Enable flag for 10% of users
  5. Enable flag for 100% of users
  6. Remove flag and dead code
TriggerwebhookIfSend EmailSMTPLog EventdatabaseUpdate CRMAPI callDonetruefalse

Workflow automation: triggers, conditions, and actions chain together to eliminate manual processes.

Comparison

Factor GitFlow Trunk-Based
Branch lifetime Days to weeks Hours to 1 day
Merge frequency Weekly/biweekly Multiple times daily
Merge conflicts Common and painful Rare and small
Deploy frequency Weekly/monthly Daily/multiple daily
Feature flags needed Optional Essential
CI/CD requirements Basic Strong (fast tests)
Code review speed Can be slow Must be fast (<4h)
Team size Any Works best 2-20
Risk per deploy Higher (big changes) Lower (small changes)
Best for Versioned releases Web apps, SaaS
Rollback method Revert merge Toggle feature flag

The Hybrid Approach

Many teams use a practical hybrid:

Free Resource

CI/CD Pipeline Blueprint

Our battle-tested pipeline template covering build, test, security scan, staging, and zero-downtime deployment stages.

Get the Blueprint
# Trunk-based with short-lived branches
main (protected, requires PR + CI)
  ├── feature/xyz (lives < 2 days)
  ├── fix/abc (lives < 1 day)
  └── release/v2.1 (only for mobile/versioned releases)

Rules:

  1. Feature branches must be merged within 2 days
  2. PRs must be under 400 lines changed
  3. CI must pass before merge
  4. Main is always deployable
  5. Feature flags for incomplete features

Branch Protection Setup

# Gitea branch protection (API)
curl -X PUT "http://localhost:3000/api/v1/repos/yash/techsaas-website/branch_protections/main" \
  -u 'yash:Eagle@2904' \
  -H 'Content-Type: application/json' \
  -d '{
    "enable_push": false,
    "enable_push_whitelist": true,
    "push_whitelist_usernames": ["yash"],
    "require_signed_commits": false,
    "enable_status_check": true,
    "status_check_contexts": ["ci/build", "ci/test"],
    "block_on_rejected_reviews": true,
    "dismiss_stale_approvals": true
  }'
docker-compose.yml123456789version: "3.8"services: web: image: nginx:alpine ports: - "80:80" volumes: - ./html:/usr/share/nginx

A well-structured configuration file is the foundation of reproducible infrastructure.

Our Recommendation

For web applications and SaaS products, use trunk-based development. The faster feedback loops, smaller merge conflicts, and continuous deployment capabilities are worth the investment in CI/CD and feature flags.

For mobile apps, libraries, and software with versioned releases that need long-term support, GitFlow or a modified version with release branches makes more sense.

At TechSaaS, we use trunk-based development with branch protection on all our Gitea repositories. Every push triggers CI (build + security scan), PRs require passing CI before merge, and we deploy from main multiple times per day. Feature flags through Directus CMS let us merge code without exposing unfinished features.

#git#trunk-based-development#gitflow#ci-cd#workflow

Related Service

Platform Engineering

From CI/CD pipelines to service meshes, we create golden paths for your developers.

Need help with devops?

TechSaaS provides expert consulting and managed services for cloud infrastructure, DevOps, and AI/ML operations.

We Will Build You a Demo Site — For Free

Like it? Pay us. Do not like it? Walk away, zero complaints. You will spend way less than hiring developers or any agency.

47+ companies trusted us
99.99% uptime
< 48hr response

No spam. No contracts. Just a free demo.