Run AI agents in parallel and clones, CI fetches and merge waits jam long before the speed of writing code becomes the limit. At Anthropic, while it still used git, source control took 34 minutes per change. Much of that jam can be reduced without replacing git, by deciding five things about how you use it. Give each agent its own working tree. Fetch file contents only when they are needed. Cut one short-lived branch per task and delete it after merge. Let each CI job fetch only what it needs. Let a merge queue protect the order in which changes reach main. Below, after looking at what jams when agents run in parallel, the article explains how to set up each of the five, following the official git, GitHub and GitLab documentation.
In parallel, git operations jam before the code does
For each task, an agent sets up a workspace, pulls the latest changes, creates a branch, pushes and runs CI. A person does this a few times a day; dozens of agents do it dozens of times as often. The bottleneck is not how fast code gets written but this setup and waiting.
A large-scale example comes from a post Anthropic published in October 2026. In its monorepo (the single repository that holds most of the company's code), merged changes went from an average of about 2,500 a day in May 2026 to more than 30,000 a day in September. On git, creating a new worktree in an agent environment took 7.1 minutes at the median and pulling the latest changes took 3.0 minutes, and source control took 34 minutes per change.
New worktree
7.1 min
Pull latest
3.0 min
Commit
18 s
Status
4.3 s
A post OpenAI published in November 2026 also says Codex multiplied parallel work and with it branches, pushes, merges and fetches from CI. A single push can start several jobs that fetch the same commit. Fetches and pushes slowed, and merges began to fail. Both companies operate at a scale far beyond most teams, but the pattern, setup and fetching that grow with the number of agents, does not depend on repository size. At both companies, what jammed was everyday practice: workspace setup, CI fetches, the number of branches and merge order.
Keep git and decide five rules for using it
This article's position is to keep git and decide how to use it. Anthropic dropped git and built its own system, but says itself that this only makes sense for enormous monorepos. OpenAI kept the git client and protocol and rebuilt only the server. Unless you merge tens of thousands of changes a day, as Anthropic does, you do not need to rebuild the server; changing how you use git is enough.
There are five decisions, and each prevents something specific. Separate working trees keep agents from overwriting each other's files. Fetching contents later cuts the wait for workspace setup. Short-lived branches keep the branch list from growing without bound and shorten the time each change spends away from main. Narrow CI fetches stop jobs from downloading the same commit in full again and again. A merge queue stops changes that pass on their own but break in combination before they reach main.
Workspace
- This article's answer
- One working tree per agent
- What it prevents
- Agents overwriting the same files
How much to fetch
- This article's answer
- Fetch file contents only when needed
- What it prevents
- Waiting on workspace setup
Branches
- This article's answer
- One per task, deleted after merge
- What it prevents
- An ever-growing branch list
CI
- This article's answer
- Each job fetches only what it needs
- What it prevents
- Full downloads of the same commit
Integration into main
- This article's answer
- A merge queue protects the order
- What it prevents
- Breakage when changes combine
Give each agent its own working tree
When several agents run on one machine, do not clone once per agent. Add working trees to a single clone with git worktree add. A linked worktree shares everything with the main repository except per-worktree files such as HEAD and the index, so no objects are fetched again. git refuses to check out a branch that another worktree already has checked out, so giving each agent its own branch becomes a requirement. When a task is done, remove its worktree with git worktree remove. Deleting the directory by hand leaves administrative files behind; clean those up with git worktree prune.
Make the base clone a blobless clone. If agents run in separate containers or on separate machines, they cannot share working trees, so make each agent's clone a blobless clone. Created with git clone --filter=blob:none, it downloads every commit and tree and fetches file contents (blobs) when they are needed. This mechanism is called partial clone. In a 2020 GitHub Blog post, Derrick Stolee explains that in a blobless clone, git log and git merge-base behave as in a full clone, while git diff and git blame download file contents on first use. Agents walk history when they rebase and merge, so a blobless clone suits them better than a shallow clone, which cuts history, or a treeless clone, which also fetches trees later. If the repository is not large, a full clone is fine.
Full
- Downloads up front
- Everything
- Suits
- Daily work in repositories of reasonable size
Blobless (--filter=blob:none)
- Downloads up front
- Commits and trees
- Suits
- Work in large repositories; build environments reused across builds
Treeless (--filter=tree:0)
- Downloads up front
- Commits
- Suits
- Environments discarded after one build
Shallow (--depth=1)
- Downloads up front
- The tip commit only
- Suits
- Environments discarded after one build
A partial clone must always be able to reach its remote, and because missing contents are fetched one at a time, operations that read many of them are slow. The git documentation shows how to prefetch the needed objects with git rev-list before commands such as git log -p. Agents are always online, so the need to reach the remote rarely matters.
If the repository is large and an agent's work stays within a few directories, narrow the working tree too, with git sparse-checkout set. Only the working tree is narrowed; history is unchanged. The git documentation marks the command as experimental and warns that some operations, such as git grep, can return partial results because they do not look outside the sparse area. git also ships Scalar, a command that sets up partial clone, sparse-checkout and background maintenance in one step.
One short-lived branch per task, deleted after merge
Have agents cut one branch per task, with one pull request each. The smaller the task, the less time it spends away from main, and the fewer merge conflicts and the less code a person has to read in review. A common prefix such as agent/ sets agent branches apart from people's and makes them easy to clean up together.
Left alone, branches pile up one per task. GitHub has a setting, "Automatically delete head branches", that deletes a pull request's branch after it merges; repository admins turn it on under Settings, General. Branch protection rules can keep a branch from being deleted, and for pull requests from forks, the fork's setting applies. Branches of pull requests closed without merging need separate cleanup. Locally, git fetch --prune removes tracking refs for branches deleted on the remote.
Keeping the branch list small matters more as scale grows. OpenAI's post points to the way a git server sends a list of every branch at the start of a push, and gives a general example: with millions of branches, that list alone can exceed 100 MiB. Anthropic also discourages branches other than main and release branches.
Let each CI job fetch only what it needs
Every agent push starts several CI jobs, and each fetches the same commit. Cut what one job fetches and the total load drops with it. Decide how each job fetches by what it needs.
Jobs that only build and test need just the tip commit. In GitHub Actions, actions/checkout defaults to a fetch-depth of 1 and fetches only the tip commit. The README warns that a shallow history can break commands that need history, such as merge-base. Jobs that need history, for example to find changed files, set fetch-depth to 0 to fetch the full history. Setting the filter input to blob:none at the same time makes it a partial clone that fetches file contents later. There is also a sparse-checkout input that narrows the directories placed in the working tree, but when filter is set, the sparse-checkout setting is not used, so choose one or the other.
Jobs that only need a diff can skip the checkout. Comparing two commits through GitHub's REST API returns the commits and a per-file diff. It returns at most 300 files for the whole comparison, and at most 250 commits without pagination, so the job has to check the counts. Anthropic, too, lets CI jobs ask an API for a diff against the merge base.
On self-hosted runners, keep a reference repository on each machine and clone with git clone --reference to borrow objects from it, which cuts how much is fetched. The git documentation warns that a clone that keeps borrowing can break if branches are deleted in the reference repository, so add --dissociate to copy the borrowed objects into the clone afterwards.
Let a merge queue protect the order of changes into main
When many agent pull requests pass at once, each can pass its own tests and still break in combination. This article recommends handing that check to a merge queue instead of relying on human review. In review, people should focus on whether the intent of the change is right.
You enable GitHub's merge queue with the "Require merge queue" branch protection setting. For each queued pull request, it creates a temporary branch with the latest base branch plus every pull request ahead of it, runs CI there, and merges in order once checks pass. CI workflows must run on the merge_group event as well as pull_request; otherwise the required checks are never reported and the merge fails. If one pull request's CI fails, only that pull request leaves the queue, and the temporary branches behind it are rebuilt. GitLab's merge trains (Premium and above) work the same way, running pipelines in parallel that each include the changes ahead. By default a train runs up to 20 pipelines in parallel.
Join the queue
A pull request whose required checks pass
Test with changes ahead
On a temporary branch with latest main and the changes ahead
Merge in order
Drop only failures and rebuild the rest
When the queue gets congested, tune its settings. On GitHub, build concurrency can be set from 1 to 100, and the maximum number of pull requests merged at once has the same range. If flaky tests are common, a setting lets failures inside a group pass as long as the last pull request in the group passes. The documentation warns that jumping the queue forces a rebuild of every in-progress temporary branch, so do not let agents do it.
Another approach drops the merge queue and fixes breakage with tests after merge. Anthropic writes that at tens of thousands of merges a day it could not replicate a merge queue that locks the whole repository, and invested in automated tests after merge and before deploy. That approach only works when post-merge tests are fast and a broken change can be reverted at once. Short of that scale, a merge queue is the safer choice.
Measure, then change workspaces, branches, CI and merging in that order
Decide where to start by measuring. Look at how long agents spend setting up workspaces, pulling the latest changes, checking out in CI and waiting in the merge queue, and you will see where a change pays off.
As a rough order: first, split agent workspaces into worktrees and make the base clone blobless if needed. Next, settle branch naming and automatic deletion. Then sort CI jobs by whether the tip commit, a partial clone or a diff from the API is enough. Last, add a merge queue and tune its settings when it gets congested. The first three need only git and hosting settings and are easy to roll back.
Measure
Workspace setup, pulls, checkouts, queue waits
Separate working trees
Worktrees, blobless clone if needed
Set branch rules
A prefix and auto-delete after merge
Cut CI fetches
Shallow fetch, partial clone, API diffs
Add a merge queue
Tune settings when congested
This article draws on the official git, GitHub and GitLab documentation and a GitHub Blog post, and cites the posts in which Anthropic and OpenAI rebuilt their source control as large-scale examples. The five decisions, the recommendations in each section and the order in the last section are this article's position. The two companies' numbers were measured and reported in their own environments. Command behavior was checked against the git 2.5x documentation. Sources checked on November 21, 2026.