Quick revision
The short answer
In trunk-based development, everyone merges short-lived branches into main at least daily and main is always releasable; unfinished features hide behind feature flags. GitFlow uses long-lived develop and release branches, which suits scheduled releases and maintenance of several versions. For a Spring Boot service deployed several times a day, trunk-based development is the better fit, because it avoids long merges and integration delays; GitFlow still makes sense for products that support several released versions at once.
What to remember
In this answer, we compared the two models. GitFlow uses long-lived develop and release branches and suits scheduled releases with maintenance of several versions. Trunk-based development merges short-lived branches into an always releasable main at least daily, with unfinished features behind flags. For a Spring Boot service deployed several times a day, trunk-based development reduces merge conflicts and integration delays, while GitFlow still fits products that support several released versions.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
In trunk-based development, everyone merges short-lived branches into main at least daily and main is always releasable; unfinished features hide behind feature flags. GitFlow uses long-lived develop and release branches, which suits scheduled releases and maintenance of several versions. For a Spring Boot service deployed several times a day, trunk-based development is the better fit, because it avoids long merges and integration delays; GitFlow still makes sense for products that support several released versions at once.
Why this question is asked
How a team branches decides how fast it can integrate and ship. A branching model that worked for a product released twice a year can become the main bottleneck for a service that deploys every hour. Interviewers ask this comparison to see whether we understand what each model optimises for, rather than repeating that one is modern and the other old. In this answer, we will recap what a branching strategy is, walk through GitFlow and trunk-based development, see why frequent deployment favours trunk-based work, look at feature flags, and finish with the cases where GitFlow still fits.
1A Quick Recap of Branching Strategies
A branching strategy is a team agreement about which branches exist, how long they live, and how code travels from a developer's machine to production. The central trade-off is integration: the longer code lives on a separate branch, the more it drifts from everyone else's work, and the harder and riskier the eventual merge becomes. A merge conflict is the visible part; the invisible part is two changes that merge cleanly but break each other's behaviour.
2How GitFlow Works
GitFlow, described by Vincent Driessen in 2010, has two permanent branches. main holds released code, with a tag for each release. develop collects finished features for the next release. Each feature gets a feature branch from develop and merges back when done. When a release is due, a release branch is cut from develop, stabilised with fixes only, then merged into main and back into develop. Urgent production fixes use a hotfix branch from main, merged into both.
This gives a clear structure for software released on a schedule, for example a quarterly desktop product: develop can move on while the release branch is tested, and hotfixes can be made to the released version. But every change passes through several merges, and features often live on their own branch for weeks. Its author later noted that it fits versioned software better than continuously delivered web applications.
3How Trunk-Based Development Works
In trunk-based development there is one long-lived branch, main, often called the trunk. Developers work in small branches that live hours or a day or two, open a pull request, pass CI and review, and merge into main. Main is kept releasable at all times, and in a continuous delivery setup each merge to main produces an artifact that can be deployed.
| Aspect | GitFlow | Trunk-based |
|---|---|---|
| Long-lived branches | main and develop, plus release branches | main only |
| Branch lifetime | days to weeks per feature | hours to a day or two |
| Release | cut a release branch, stabilise, merge | any commit on main can be deployed |
| Unfinished work | stays on its feature branch | merged, hidden behind a feature flag |
| Merge pain | large, late merges | small, frequent merges |
| Best fit | scheduled releases, several supported versions | continuous delivery of one version |
Notice that the branch is a short wrapper around one small change, not a container for a whole feature. A feature that takes three weeks is delivered as fifteen small merges, each one safe to deploy.
4Why Frequent Deployment Favours Trunk-Based Work
A service that deploys five times a day has only one version in production at a time, and the goal is to get small, tested changes there quickly. With GitFlow, each change would wait on develop until a release branch is cut, then be merged twice more. That adds delay and ceremony without any benefit, because there is no scheduled release to protect.
Trunk-based work also reduces risk, which surprises people. When ten developers merge small changes daily, conflicts are small and found within hours, and a broken deployment points to a handful of commits. When feature branches live for three weeks, merges are large, conflicts are resolved by people who no longer remember the details, and a failing release contains weeks of changes. Research from the DORA programme has repeatedly linked trunk-based development with higher delivery performance, partly for this reason.
5Hiding Unfinished Features Behind Flags
The natural question is what to do with a feature that is not finished when its code is merged. The answer is a feature flag: a runtime switch, read from configuration or a flag service, that decides whether the new code path runs. The code ships to production turned off and is turned on when it is ready, possibly for a few users first.
This separates deployment, putting code into production, from release, letting users see it. The cost is that flags must be cleaned up once a feature is fully on, or the code fills with dead branches; teams usually give each flag an owner and a removal date.
6When GitFlow Still Fits
GitFlow, or a simplified version with release branches, is still a good fit when we really have several versions in the field. An on-premises product where customers run versions 3, 4 and 5, a mobile app waiting for store review, or a library with long-term support lines all need branches where a released version can receive fixes without new features. Even then, many teams keep development itself trunk-based on main and only cut release branches for maintenance, which keeps most of the benefits.
7Follow-up questions
Is trunk-based development possible without feature flags?
For small changes, yes, because each one is finished in a day. For larger features, the alternatives are building the change behind a new endpoint that nothing calls yet, or using branch by abstraction, where a new implementation is built behind an interface and swapped in when ready. Flags are the most general tool, but not the only one.
Does trunk-based development mean no code review?
No. Short-lived branches with pull requests, CI and review are the common form. Some teams push directly to main with pair programming instead, but review through small pull requests is entirely compatible with merging daily.
What is GitHub Flow?
It is a simple model close to trunk-based development: main is always deployable, work happens on short branches, and changes are merged through pull requests and deployed. It drops GitFlow's develop and release branches entirely.
8Conclusion
In this answer, we compared the two models. GitFlow uses long-lived develop and release branches and suits scheduled releases with maintenance of several versions. Trunk-based development merges short-lived branches into an always releasable main at least daily, with unfinished features behind flags. For a Spring Boot service deployed several times a day, trunk-based development reduces merge conflicts and integration delays, while GitFlow still fits products that support several released versions.
Open with
For a service deploying several times a day I would choose trunk-based development. In trunk-based work, main is the only long-lived branch and it is always releasable. Developers make small branches that live hours or a day, open a pull request, pass CI and review, and merge, and each merge can be deployed.
Then, if they want more
GitFlow, in contrast, has a develop branch for the next release, feature branches that often live for weeks, release branches that are stabilised before merging into main, and hotfix branches. That structure helps when releases are scheduled, but for continuous deployment it only adds delay: changes wait on develop and get merged several times.
Long branches also make merges large and late, so conflicts and integration bugs pile up, whereas daily merges keep them small and easy to trace. The obvious question is unfinished features, and the answer is feature flags: the code is merged and deployed switched off, which separates deployment from release, with flags removed once the feature is fully on.
I would still use release branches, GitFlow style, for a product where customers run several versions and each one needs fixes.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Apache Maven guides, Gradle user manual
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Compare trunk-based development with GitFlow for a team deploying a Spring Boot service...": https://scrivio-interview-library.netlify.app/java/version-control-and-ci/36e6c1d2ee/