# fix\(server\): bulk worktree launches no longer fail on Git races · PR \#17197 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/17197)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: open

Source repository: Unavailable fork

Source branch: t3/fix-concurrent-worktree-creation

Target branch: main

Head commit: 1ed1257f32758b62df2afdb2dc45697131c6ae21

[Discussion and reviews](https://git.cafe/pingdotgg/t3code/pull/17197)

[Commits](https://git.cafe/pingdotgg/t3code/pull/17197/commits?format=markdown)

[Files changed](https://git.cafe/pingdotgg/t3code/pull/17197/diffs?format=markdown)

## Description

---

Concurrent launches into one repository can fail on fetch ref locks, occupied branch names or paths, and shared Git config writes. Retry can hit the same collision again.

Concurrent fetches of the same ref now share their in-flight result, including the `fetchWorktreeBaseCommit` path used by start-from-origin launches. Branch/path collisions retry with a bounded suffix (temporary branches get a fresh hash), and branch creation, merge-base config writes, and renames share a lock keyed by the Git common directory. Checkout stays parallel. A launch never retries once it has claimed a worktree path, and retrying a failed thread keeps its existing run and message.

Rebased onto main at `5bb54a0f77`, resolving conflicts with main's test pruning without restoring unrelated deleted cases.

Validation on macOS:

- Controlled process fixtures verify six concurrent public fetches or launch-base fetches share one fetch, return the same result, and fetch again after completion. Removing the launch-base fix makes its regression fail with six fetches instead of one.
- Real Git service integration covers six simultaneous launches both with and without `startFromOrigin`. Origin advances beyond the local branch; every origin-based launch starts at the fetched commit and keeps the remote comparison base. Occupied branches, uncommitted work, an unrelated directory, and the local base branch are preserved.
- Both complete touched suites pass: 209 tests across `ThreadLaunchService.test.ts` and `GitVcsDriverCore.test.ts`.
- Server typecheck, targeted lint, formatting, and diff checks pass. Lint reports three existing warnings outside the changes.

Fetch sharing is checked with a controlled process fixture; real Git launch tests use a local remote. No live network race or client UI verification was performed. Coordination is local to one Git driver instance; external Git processes do not use its locks. As with Git's existing `worktree add -b`, an attempt that fails before claiming a worktree can leave an unused branch. Collision retries skip it without deleting existing work.

Implementation and validation: GPT-6.1 Sol (high) through the Codex harness in T3 Code.

