Git Workflow Strategies for Teams
Compare feature branches, GitFlow and trunk-based development, then see the commands, branch protection and feature flags that make each one work in a real team.

A feature branch lived for three weeks on one of my early projects. When we finally tried to merge it, Git reported 40 conflicting files, two of which had been rewritten on main by someone else. The merge took a full day, and nobody trusted the result enough to deploy it that week. The code on the branch was fine. The workflow was the problem, because it let integration debt pile up where nobody could see it.
Choosing a Git workflow is mostly a decision about how long work is allowed to stay away from main. This post compares the three strategies I see most often, shows the commands and settings that make each one work, and gives you a rule for choosing.
Quick takeaways
- The deciding factor is branch lifetime: the longer work diverges from
main, the more it costs to merge. - Feature branches with pull requests suit most teams, as long as branches live for days, not weeks.
- GitFlow fits software with versioned releases that must be supported in parallel; it is overhead for a continuously deployed web app.
- Trunk-based development works when you have fast CI and feature flags to hide unfinished work.
- Whichever you choose, enforce it with branch protection rather than with a wiki page.
What is the feature branch workflow?
Everyone works on short branches created from main and merges through a pull request. It is simple, review is built in, and main stays releasable. Its weakness is that nothing stops a branch from growing old.
git switch main && git pull --ff-only
git switch -c feature/invoice-export
# small commits while you work
git add -p && git commit -m "Add CSV export for invoices"
# before opening the PR, replay your work on the latest main
git fetch origin && git rebase origin/main
git push -u origin feature/invoice-export
gh pr create --fill
Rebasing before you open the pull request keeps history linear and surfaces conflicts while the change is still small. A habit that helps: if a branch is older than three days, either merge what you have behind a flag or split it.
When does GitFlow make sense?
GitFlow uses long-lived main and develop branches plus feature/*, release/* and hotfix/* branches. It gives a clear release process and supports maintaining several released versions at once, which matters for mobile apps, desktop software or libraries where users do not upgrade on the same day.
For a web service that deploys many times a week, it adds ceremony: two integration branches, release branch merges back into both, and a lot of places for a hotfix to be forgotten. If your CI/CD deploys from main, you probably do not need it.
How does trunk-based development work in practice?
Everyone integrates into main at least daily, with branches that live for hours. Unfinished work ships to production switched off. A minimal feature flag looks like this:
const flags = {
invoiceExport: process.env.FLAG_INVOICE_EXPORT === "true",
};
export function exportMenu(user: User) {
const items = [{ label: "Print", action: "print" }];
if (flags.invoiceExport || user.isInternal) {
items.push({ label: "Export CSV", action: "export-csv" });
}
return items;
}
Flags are not free. Every flag is a branch in your code that needs a test for both states and a removal date; stale flags are their own kind of technical debt. Trunk-based development also depends on fast, trusted CI, so a broken commit is detected and reverted in minutes. The pipeline described in CI/CD with GitHub Actions is the prerequisite.
How do I choose a workflow for my team?
| Situation | Starting point |
|---|---|
2-5 engineers, deploy from main | Feature branches, or trunk-based with flags |
| 5-15 engineers, pull request reviews required | Feature branches with branch protection and size limits |
| Versioned releases, several supported at once | GitFlow, or release branches cut from trunk |
| Large team, strong CI, daily deploys | Trunk-based with flags and merge queues |
Team size matters less than release cadence and how quickly your CI answers. If a full pipeline takes 40 minutes, short-lived branches will feel painful regardless of what the diagram says.
How do I enforce the workflow instead of just documenting it?
Branch protection turns your convention into a rule. With the GitHub CLI you can apply the same protection to every repository from a JSON file:
cat > protection.json <<'EOF'
{
"required_status_checks": { "strict": true, "contexts": ["test"] },
"enforce_admins": true,
"required_pull_request_reviews": { "required_approving_review_count": 1 },
"restrictions": null
}
EOF
gh api -X PUT repos/OWNER/REPO/branches/main/protection --input protection.json
This requires an up-to-date branch, a passing test check and one approving review before anything reaches main. Pair it with squash merging for tidy history and a pull request template that asks "what does this change and how was it tested". Good reviews matter as much as the rule; see Code Review Practices That Catch Bugs Without Killing Velocity.
Which habits matter more than the workflow?
- Small, focused commits. They are easy to review and easy to revert.
- Messages that explain why. "Fix retry loop" helps nobody in a year; "Stop retrying 4xx responses to avoid duplicate charges" does.
- Push regularly. Work that exists only on your laptop is invisible and unbacked.
- Delete merged branches. Turn on auto-delete in repository settings.
What should I do next?
Run git branch -r --sort=committerdate and look at the oldest remote branches. If any is older than a week, ask its owner what is blocking the merge. Then write down your team's maximum branch age, enable branch protection with the JSON above, and review the result after a month. For monorepos, the same ideas combine with path filters, as covered in CI/CD Pipeline Patterns for Monorepos.
Uğur Kaval
AI/ML Engineer & Full Stack Developer specializing in building innovative solutions with modern technologies. Passionate about automation, machine learning, and web development.


