Trunk-Based Development vs Gitflow for Agent Teams

Compare trunk-based development vs Gitflow in 48 local runs. See how merge cadence, review queues, and CI cost change for teams running parallel coding agents.

Four-row chart compares total logical queue wait in the local fixture. Gitflow release batch took 12 ticks, Gitflow daily and the one-slot trunk queue each took two, and the two-slot trunk queue took zero.

Trunk-based development vs Gitflow is a choice about where parallel changes come together and how long they wait. Trunk-based development integrates small changes into one main branch frequently. Gitflow develops features against a separate integration branch and uses release branches to prepare versions. Start with short-lived branches and frequent integration when one product line ships continuously. If you maintain several supported versions, choose the release structure separately from the cadence for merging new work.

We compared four integration policies in 48 local Git runs. The one-change trunk queue lowered the average total queue wait from 12 to 2 logical ticks against release-batched Gitflow. Daily-batched Gitflow also took 2 ticks. Both branching families hit the planted conflicts and finished with identical tested behavior. The trunk queues ran the full suite more often.

How trunk-based development and Gitflow handle the same change

Under trunk-based development, engineers and agents work in small changes that return quickly to main. Many teams use short-lived pull request branches and require review before integration. A release can come from a known commit or tag on trunk. If an older version needs maintenance, a team can create a branch for that version while active development continues on trunk. Trunk-based development reference · Branching for release

In Vincent Driessen's Gitflow model, main represents production releases and develop is the integration branch for features. Feature branches return to develop. A release branch starts from develop when the planned set of features is ready for stabilization. The release merges into main, receives a tag, and its fixes feed back into develop. The hotfix path starts from the production branch and brings the fix back to the active development or release line. Driessen later recommended a simpler model for continuously delivered software while noting that Gitflow may still fit explicitly versioned software. Original Gitflow description and 2020 note

Decision Trunk-based development Gitflow
Where feature changes meet The shared trunk, often main The long-lived develop branch
How changes travel Small changes move into trunk frequently, often through a short-lived review branch Feature branches merge into develop, with a separate release branch for stabilization
Where production gets a version A known trunk commit or tag, or a maintenance branch if needed A tagged merge into the production branch
What the team has to coordinate Review and integration against the current trunk Review into develop and the handoff of release or hotfix changes between lines

GitHub flow is a separate workflow with a similar name. GitHub describes it as opening a branch, getting feedback on a pull request, and merging into the default branch. If the team keeps branches short and integrates frequently, that pattern can support trunk-based development. GitHub flow documentation · DORA's trunk-based development guidance

The 48-run experiment

We used a small Python task router and four deterministic patches representing changes from parallel writers. One patch added a priority field and report label. Another added retry state. A third changed the capacity policy. The last added status reporting. The retry and capacity changes had an interaction that a combined test could catch after both were present. We included fixtures with overlapping lines in the model or reporting code as well.

The 12 scenarios varied finish order and where patches overlapped. Each ran through the same four policies. Within a scenario, every policy used the same base commit, immutable patch set, ready ticks, suites, and resolution rules. The fixture verified patch hashes and checked that all four final Git trees and behavior signatures matched. The final full suite passed in every run.

Policy When ready changes integrated Total wait, mean ticks per scenario Branch age, mean ticks Maximum ready changes pending, mean per scenario Full-suite runs, mean per scenario
Release-batched Gitflow One integration at tick 5 12.00 3.00 4.00 2.00
Daily-batched Gitflow Integration batches at ticks 2 and 4 2.00 0.50 3.00 3.00
Trunk queue, capacity 1 Admit one ready change per tick 2.00 0.50 2.00 6.00
Trunk queue, capacity 2 Admit up to two ready changes per tick and apply them in sequence 0.00 0.00 2.00 6.00

The wait column adds the delay of all four changes in a scenario, then averages that sum across the scenarios. A tick is an ordering unit chosen for the experiment. For instance, the four changes became ready at ticks 1, 2, 2, and 3. Holding them until tick 5 produced waits of 4, 3, 3, and 2 ticks, totaling 12. The maximum pending count measures ready changes before a tick's integrations, so a queue can register two pending changes and still clear them that tick.

Earlier integration changed the delay and the test bill

Bringing Gitflow batches forward from tick 5 to ticks 2 and 4 reduced total wait by 10 ticks. That matched the one-change trunk queue's total wait and branch age in this fixture. It still held as many as three ready changes at once, versus two for the trunk queue, and ran the full suite three times per scenario, versus six. Raising the trunk queue's capacity from one to two eliminated scheduled wait for these ready times. Both queues still integrated changes one at a time.

Each policy recorded eight textual conflicts and twelve semantic integration failures total across the twelve scenarios. Every policy ran each change's unit suite. A test that checks a routed retry task when both patches are present answers a different question from a test of the retry field in isolation. In the one-change trunk queue, eleven semantic failures appeared after a text-clean integration. In the release-batched Gitflow policy, four did. The total semantic failure count stayed at twelve for each. Treating a clean merge as clearance to ship would have missed a known behavior change. A merge queue that tests the combined tree addresses that integration risk.

The suite counts describe how this fixture checked each candidate and batch. A team could design a different check matrix or choose different CI capacity. The comparison used local Git, deterministic stand-ins for agent patches, and a small Python program. The results cover logical delay and local test counts. Review quality, hosted CI latency, adoption cost, and production incidents remain unmeasured.

Choosing a policy for parallel coding agents

For a team that deploys from one current product line, begin with one integration target and short-lived review branches. Assign each agent a small task that can merge independently. Give one person ownership of changes to a shared interface. If two agents depend on the same change, agree which patch lands first and record the dependency in the pull requests. Stacked pull requests for coding agents describes a way to make that order visible to reviewers.

After a short-lived branch lands, check it before pruning it locally. Confirm that the intended change reached the integration branch, including cases where a squash merge created a different commit.

For a versioned product, write down which versions need fixes and how those fixes reach the active development line. A team might integrate features frequently on trunk and cut a maintenance branch when an older version needs support. A team already using develop can keep it while moving feature integrations earlier. Pick the branch model for the versions you support and assign a separate integration deadline for each ready change. In our daily-batched case, changing the integration schedule recovered the same measured wait as the one-change trunk queue.

An integration deadline needs an owner. Protect the branch people deploy from and route changes to the maintainers who can review them. Use CODEOWNERS for agent pull requests to send shared-interface changes to a named reviewer. When an agent's change affects authentication, data migration, or a public schema, record the check and the person deciding whether it can land. A queue can run the required checks on candidate changes in order. The team still needs enough review and CI capacity to admit them. On GitHub, a repository using Actions for required queue checks must configure the merge_group event so CI reports the check for the queued candidate. GitHub merge queue documentation

A rollout that tests the cause of delay

Start with one repository. Record when changes become ready for review, when they have the required approvals, when they enter the integration queue, and when they merge. Report review wait and integration wait separately. Use median and 90th-percentile wait so a single failed build or a rare large change has a visible effect. Count full-suite runs and retries alongside wait. These measurements tell you whether time goes to human review, an integration batch, or the CI jobs needed to clear the queue.

Change one policy for a short trial. If approved PRs wait days for a batch, integrate into the existing shared development branch more frequently before replacing the whole branch model. If the team already integrates continuously but candidates wait for the same single runner, try adding capacity to the queue while retaining the checks. If reviewers keep waiting on dependent changes, split the work by ownership or reduce the number of changes that need the same interface. A shared coordination record for agents can keep an owner, a dependency, and the required approval visible to contributors.

Before the trial, agree when to stop admitting changes to the target branch. A failed combined test should give the reviewer a named owner, the involved changes, and the observed failure. If a bad change reaches shared history, choose with the maintainer whether to fix forward or use a rollback that preserves later work. Keep the fix path and release owner in the same record as the integration policy. At the end of the trial, compare ready-to-merge time, full-suite load, and unresolved failures. Keep the policy that meets your target with the review capacity you actually have.

Frequently asked questions

What is the difference between trunk-based development and Gitflow?

Trunk-based development integrates small changes into one shared trunk frequently. In the original Gitflow model, features integrate into a long-lived develop branch, release branches stabilize versions, and the production branch records tagged releases. The best fit depends on supported versions and how soon independent changes need to meet.

Can trunk-based development use pull requests and code review?

Yes. A team can review small changes on short-lived topic branches and merge them into trunk after the required checks pass. The branch lifetime includes time spent waiting for review. Keep a clear owner for each change and use a merge queue when several approved changes need integration checks together.

Can a trunk-based team maintain old releases?

Yes. A team can release from a known trunk revision, then create a maintenance branch for a version that needs fixes. Decide how each fix will reach the supported version and the active development line. Keep ordinary feature integration on the trunk so the maintenance branch has a defined job.

When should a team keep Gitflow?

Gitflow can fit a team that stabilizes explicitly versioned releases and supports more than one version at a time. Make responsibility for fixes between develop, release, and production branches explicit. If approved feature work is waiting, test earlier integration into develop before changing the full branch model.

Does trunk-based development eliminate merge conflicts between coding agents?

Shorter branch lifetimes give contributors earlier feedback about overlapping changes. In the local fixture, every policy still hit the same number of textual conflicts and semantic failures. Keep an owner for shared files or interfaces, test the combined change, and get a human decision when the interaction needs a product choice.