0

The Git workflow that actually works for small teams

Every team I've joined has the same problem: their Git workflow is either too simple (everyone commits to main) or too complex (Gitflow with 5 branch types nobody understands).

Here's what actually works for teams of 2-10 developers.

The Setup

Two permanent branches:

  • main — always deployable
    • staging — integration testing

That's it. No develop, no release/v1.2.3, no hotfix/urgent-fix-please-work.

The Flow

1. Feature work

git checkout main
git pull
git checkout -b feature/add-payment
# work, commit, push
git push -u origin feature/add-payment
# open PR to staging

2. Code review on PR

PR targets staging, not main. This lets multiple features land in staging for integration testing before going to production.

3. Deploy staging

Merge PR → auto-deploy to staging environment. QA tests here. If something breaks, it only affects staging.

4. Promote to production

When staging is stable:

git checkout main
git merge staging
git push  # triggers production deploy

5. Hotfix

git checkout main
git checkout -b hotfix/fix-crash
# fix, commit
# PR directly to main (skip staging)
# then merge main back to staging

Why This Works

  • Simple: two branches, one flow
    • Safe: staging catches integration issues before production
    • Fast: hotfixes go straight to main when needed
    • No merge hell: short-lived feature branches merged frequently

Rules

  1. Feature branches live max 3 days. Longer = smaller scope.
    1. Rebase before merging. Clean history.
    1. Squash merge to staging. One commit per feature.
    1. Delete branches after merge. No branch graveyard.

What Doesn't Work

  • Gitflow: Too many branches for small teams. Nobody remembers which branch to target.
    • Trunk-based with feature flags: Great for big companies with CI/CD maturity, overkill for small teams.
    • Everyone on main: Works until two people edit the same file. Then it's chaos.

What Git workflow does your team use? Curious to hear what works for others.


All rights reserved

Viblo
Hãy đăng ký một tài khoản Viblo để nhận được nhiều bài viết thú vị hơn.
Đăng kí