Reproduced on Linux in the web dev app at 70e5e384da: added a folder initialized with git init -b main, selected New worktree, and sent a message. Checkout failed with git worktree add failed (ref_not_found) before the agent started; Retry failed identically. The same flow in a repository with one initial commit created the worktree and completed the turn.
[Bug]: New worktree threads fail in a repository with no commits#22017
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- Run
git initin an empty folder. Do not commit anything. - Add the folder as a project in T3 Code.
- Set new threads to start in a new worktree (Settings, or the project's default).
- Start a new thread and send a message.
Expected behavior
The thread starts. A repository with no commits has nothing to check out, so the thread should run in the project folder, as it does for a non-Git project.
Actual behavior
Setup fails at the checkout step and no turn starts:
| 1 | Workspace preparation failed during provision worktree: Git command failed in GitVcsDriver.createWorktree (<repo>): git worktree add failed |
Git itself reports fatal: invalid reference: main, because main has no commit yet. Retry fails the same way. The only way forward is to make a commit or switch the thread to the main checkout.
Impact
Blocks work completely
Version or commit
main @ 673c5e3b3
Environment
Linux, git 2.43+. Reproduced by hand with git init -b main repo && cd repo && git worktree add -b t3/x ../wt main, which exits 128 with fatal: invalid reference: main. Not provider specific.
Logs or stack traces
| 1 | $ git init -q -b main repo && cd repo |
| 2 | $ git worktree add -b t3/x ../wt main |
| 3 | fatal: invalid reference: main |
Workaround
Make an initial commit, or start the thread in the main checkout.
Prior work
- #2148 was closed as not reproducible for the dead-route symptom. The closing comment notes that worktree creation without a commit still fails and that a local-mode fallback was not implemented.
- #15580 added that fallback in
ThreadLaunchServiceand was closed in favor of #17791. - #17791 only adds a pre-launch check for the MCP
t3_thread_launchtool. It accepts a repository whoseHEADhas no commit and leaves that case to #15580, so the failure above still happens on current main for every launch path.
The candidate fix passes all 40 focused launch-service tests. Review identified a maintainer decision: the shared fallback also changes t3_thread_launch, so an explicit new-worktree request can execute in the project folder instead. Stopped before publishing a PR under the triage rule for MCP tool-surface changes. The issue remains open.
Reproduced again in the Linux web dev app on 05b697f6a2: added a folder initialized with git init -b main, selected New worktree, and sent a message. Workspace preparation failed with git worktree add failed (ref_not_found) before a provider turn started. A regression test and focused fix are in progress.