Sub topic 16
Choosing a strategy for your team
What this chapter assumes
You know how branches, merges, rebases, and pull requests work. You have also seen GitHub Flow, trunk-based development, and Gitflow described. This chapter helps you pick one for a real team.
Three questions that narrow the choice
No strategy is best everywhere. Three facts about your team settle most cases:
- Release cadence. Do you ship continuously, on a schedule, or as numbered versions that customers install?
- Team size and experience. How many people merge each day? Are they comfortable with small, frequent merges?
- Deployment automation. Can a merge to
mainbe tested and deployed with no manual steps?
Comparing the options
| Strategy | Best fit | Branches in use | Main cost |
|---|---|---|---|
| GitHub Flow | Web apps deployed often, small to mid-sized teams | `main` plus short feature branches | Needs reliable tests. It has no built-in way to maintain old versions. |
| Trunk-based | Frequent deploys, strong CI, experienced teams | `main` plus branches lasting hours, or direct commits | Needs feature flags and fast CI. |
| Gitflow | Versioned releases, several supported versions | `main`, `develop`, feature, release, hotfix | Many long-lived branches, extra merges, slower feedback. |
Reading the signals
- Deploys several times a week: GitHub Flow or trunk-based development. Move toward trunk-based if feature branches routinely live longer than a day or two and conflicts are your main pain. Use feature flags to merge unfinished work.
- Scheduled or versioned releases: Gitflow fits. A lighter variant keeps one
main, cutsrelease/x.ybranches when needed, and backports fixes withgit cherry-pick -x. - Mixed situation: A hosted service with one mobile app may use GitHub Flow for the service and release branches for the app. One repository can have different rules for different deliverables.
Enforce the choice
A strategy that exists only in a wiki drifts. Encode it in branch protection:
- Require pull requests and at least one review on
main. - Require status checks to pass before merging.
- For GitHub Flow and trunk-based work, allow only squash or rebase merges. This keeps history linear.
- For Gitflow, protect both
mainanddevelop, and allow merge commits so branch history is preserved.
Match the rules to the workflow. Requiring two reviewers on a trunk-based project, for example, pushes people toward larger, less frequent merges.
Common mistakes
- Using Gitflow for a service that deploys daily. The
developand release branches add delay without protecting anyone. - Going trunk-based without fast CI or feature flags. Broken code then reaches users or blocks everyone.
- Letting feature branches live for weeks under any strategy. Conflicts and review size grow with branch age.
- Choosing by popularity instead of by the three questions above.
Review the choice when your release cadence, team size, or automation changes. A strategy is a tool you can swap.
Exercise
A team of six builds an internal web dashboard. Every merge to main runs a full test suite and deploys automatically within ten minutes. They have no feature flags, and only one version of the dashboard ever runs. Which strategy fits best, and which branch protection settings would you apply?
Show answer
GitHub Flow fits best. Deployment is automated and there is a single version, so Gitflow's release and hotfix branches add nothing. Without feature flags, trunk-based development would be risky for unfinished work. Protect main with required pull requests, at least one review, required passing status checks, and squash or rebase merging to keep history linear.