Vasu Patel logoVasu Patel
← Git Mastery
All chapters in this track
  1. 011. The Mental Model
  2. 022. Essential Setup
  3. 033. Core Daily Workflow
  4. 044. Branching
  5. 055. Merging & Conflict Resolution
  6. 066. Rebasing
  7. 077. Remote Repositories
  8. 088. Stashing
  9. 099. Undoing Things
  10. 1010. Tagging & Versioning
  11. 1111. Cherry-Pick
  12. 1212. Git Bisect & Blame
  13. 1313. Git Hooks
  14. 1414. Submodules
  15. 1515. Team Workflows
  16. 1616. Power Commands & Aliases
  17. 1717. Reflog: The Safety Net
  18. 1818. Practice Tasks
  19. 19Quick Reference Cheatsheet

Chapter 15 of 19

15. Team Workflows

15.1 GitHub Flow (Simple, fast, CI-driven)

Best for: web apps, SaaS, continuous deployment.

main
 ├── feature/login        ← branch off main
 │     ↓ (PR + review)
 └── merge to main → deploy

Steps:

  1. Branch off main with a descriptive name
  2. Commit early and often
  3. Open a Pull Request (PR) when ready for review (or as draft for early feedback)
  4. CI runs tests, reviewer approves
  5. Merge to main — triggers automatic deployment

Key rules: main is always deployable. No long-lived branches.


15.2 Gitflow (Structured release cycles)

Best for: versioned products, mobile apps, enterprise software.

main (production)
develop (integration)
 ├── feature/x  ← branch from develop, merge back to develop
 ├── release/2.1 ← branch from develop, merge to main + develop
 └── hotfix/x   ← branch from main, merge to main + develop
BranchPurpose
mainProduction-ready only
developIntegration branch
feature/*New features (branch from develop)
release/*Prep for release — only bug fixes, docs
hotfix/*Emergency fix on production
# Feature
git switch -c feature/login develop
# ... work ...
git switch develop
git merge --no-ff feature/login

# Release
git switch -c release/2.1 develop
# bump version, fix last bugs
git switch main ; git merge --no-ff release/2.1 ; git tag -a v2.1.0
git switch develop ; git merge --no-ff release/2.1

# Hotfix
git switch -c hotfix/payment main
# fix bug
git switch main ; git merge --no-ff hotfix/payment ; git tag -a v2.1.1
git switch develop ; git merge --no-ff hotfix/payment

15.3 Trunk-Based Development (TBD)

Best for: experienced teams with strong CI/CD, Google/Facebook style.

main (trunk)  ← everyone commits here directly or via very short-lived branches

Rules:

  • Branches live ≤ 1-2 days (or commit directly to main)
  • Feature flags hide incomplete features in production
  • CI must be fast and run on every commit
  • No long-lived branches — they're the enemy of TBD
# Short-lived branch style
git switch -c feature/header-cta
# finish in <2 days
git rebase main          # keep up-to-date
git push origin feature/header-cta
# immediate PR + merge

Workflow Comparison

GitHub FlowGitflowTrunk-Based
Release cadenceContinuousScheduledContinuous
Branch lifetimeDaysWeeksHours
ComplexityLowHighLow
Best forWeb appsVersioned releasesExperienced teams