Trunk-based development vs Git Flow: which branching strategy fits CI/CD?
Compare Git Flow, GitHub Flow, and trunk-based development, understand why short-lived branches fit continuous delivery, and see what it takes to adopt trunk-based development day to day.
Development$ git pull --rebase▍Every team that uses Git ends up answering, on purpose or not, one question: how long does code stay away from the main branch before it gets integrated? Days? Weeks? Hours? The answer defines your branching strategy, and it affects delivery speed more than whichever CI tool you pick.
In this article, we compare the three most common strategies, Git Flow, GitHub Flow, and trunk-based development, and show when each one makes sense. If branch and merge are still new terms, start with what is Git and GitHub.
Git Flow: the long-lived branch model
Git Flow was described by Vincent Driessen in 2010, in the article “A successful Git branching model.” It organizes work into several types of branches:
main: only receives code that went to production; every merge becomes a tagged version.develop: where features pile up for the next version.feature/*: one branch per feature, created fromdevelopand merged back into it.release/*: preparing a version (final tweaks, version number), which then goes tomainanddevelop.hotfix/*: urgent fixes created frommain.
feature/login ──┐
├──▶ develop ──▶ release/1.0 ──▶ main (tag v1.0)
feature/search ─┘ ▲ │
└─────────────┘ release fixes flow back to develop
main ──▶ hotfix/1.0.1 ──▶ main (tag v1.0.1) + develop
The model is organized and predictable, and it became very popular at a time when shipping a version was an event. It’s worth noting that Driessen himself, years later, added a note to the article: for continuously delivered web applications, he came to recommend a simpler workflow, such as GitHub Flow, and to reserve Git Flow for explicitly versioned software.
GitHub Flow: main plus short-lived branches
GitHub Flow boils everything down to one rule: main is always deployable. For any change, you create a short-lived branch from main, open a pull request (PR, a request to integrate your changes, with review), wait for CI to pass, and merge. After the merge, the deploy happens.
main ●──────●──────────●──────●──────●───▶ continuous deploy
\ / \ /
feat/search ●──● ●──● fix/header
(1-3 days) (hours)
There’s no develop and no release/*. Simplicity is the big advantage; the risk is letting feature branches grow for weeks, which brings back Git Flow’s problems.
Trunk-based development: integrate every day
In trunk-based development, everyone integrates into the main branch (the trunk, which in Git is usually main itself) at least once a day. This can happen through direct commits (common in small, experienced teams) or, more often, through branches that live a few hours and land via small PRs.
main ●──●──●──●──●──●──●──●──●──●──●──●──▶
↑ ↑ ↑ ↑ ↑ ↑
small PRs, several times a day
unfinished work hidden behind feature flags
│
└──▶ release/2.3 (optional, cut from trunk)
What about features that take weeks? They land piece by piece, switched off by feature flags (switches in the code that turn a feature on or off without a new deploy). The code is in production, but users only see it when the flag is turned on. See how to do this in a standardized way in feature flags with OpenFeature.
Releases ship straight from the trunk. When the team needs to stabilize a version, it can cut a release branch from the trunk and bring fixes over with cherry-pick, but the fix always lands in the trunk first.
Side-by-side comparison
| Git Flow | GitHub Flow | Trunk-based | |
|---|---|---|---|
| Branch lifetime | Weeks to months (develop is permanent) |
Days | Hours (or direct commit) |
| Merge conflicts | Frequent and large | Moderate | Small and rare |
| CI fit | Weak: real integration happens late | Good | Excellent: truly continuous integration |
| Release cadence | Planned, per version | Continuous | Continuous or on demand |
| Best for | Installed software with several supported versions | Web applications and small to midsize teams | Teams aiming for daily deploys with mature CI/CD |
Why trunk-based fits high performance
Research from DORA (DevOps Research and Assessment) lists trunk-based development among the technical capabilities associated with better software delivery performance. The practices it describes include keeping few active branches, integrating into the trunk at least once a day, and avoiding code freeze periods.
The reason is intuitive. Think of two friends editing the same document: if each spends a month working on a separate copy, merging everything at the end turns into an afternoon of headaches. If they merge every hour, the differences are small and easy to resolve. Short-lived branches mean small merges, fast CI feedback, and fewer surprises at deploy time.
What needs to be in place
Trunk-based isn’t just “merging earlier.” Without a technical foundation, it turns into a main that’s broken all the time. The main enablers:
- Fast CI: if the pipeline takes 40 minutes, nobody integrates several times a day. See how to cut a pipeline from 40 to 10 minutes.
- Reliable tests: a balanced suite, as in the test pyramid, that gives you the confidence to merge without fear.
- Feature flags: to integrate unfinished work without exposing it to users.
- Reviewing small PRs: PRs of a few dozen or a few hundred lines get reviewed in minutes, not days. See code review that works.
- Merge queue: a queue that tests each PR combined with the latest version of
mainbefore merging, so two PRs that are valid on their own don’t break the branch together. GitHub and GitLab offer features of this kind.
A day of work with trunk-based development
In practice, the daily flow looks like this:
# 1. Always start from an up-to-date main
git switch main
git pull --rebase
# 2. Create a short-lived branch for a small change
git switch -c feat/date-filter
# 3. Make small, frequent commits
git add -p
git commit -m "feat: add date filter to the orders list"
# 4. Before opening the PR, bring in what's new on main
git fetch origin
git rebase origin/main
# 5. Push and open the PR
git push -u origin feat/date-filter
gh pr create --fill
# 6. After the merge, go back to main and delete the local branch
git switch main
git pull --rebase
git branch -d feat/date-filter
git pull --rebase replays your local commits on top of the new commits from the remote, keeping history linear. git add -p lets you pick chunks of a file for each commit, which helps keep commits small and focused. If a branch lasts more than a day or two, it’s a sign the change could be split.
When Git Flow still makes sense
Git Flow isn’t wrong; it solves a different problem. It’s still a good choice when:
- You ship installed software (desktop app, firmware, library) and need to maintain several versions in parallel, such as 2.x receiving fixes while 3.x is being developed.
- Releases depend on slow external processes, such as regulatory approval or app store publishing with review.
- Continuous deployment isn’t possible, and each version has to be frozen and certified.
Even in these cases, many teams adopt a hybrid: trunk-based for day-to-day development and long-lived release branches only for maintaining older versions.
Checklist
- Feature branches last a day or two at most
- Everyone integrates into
mainat least once a day - The CI pipeline gives feedback within a few minutes
- Unfinished work lands protected by feature flags
- PRs are small and reviewed the same day
- A merge queue or branch protection prevents a broken
main - Git Flow reserved for software with several supported versions
The best branching strategy is the one where code spends the least possible time waiting to be integrated.