GeezerVison is showing github.com — [Bug]: New worktree threads fail in a repository with no commits · Issue #22017 · pingdotgg/t3code
[Bug]: New worktree threads fail in a repository with no commits #22017DescriptionBefore 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 init in 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:
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 @ 673c5e3
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
$ git init -q -b main repo && cd repo
$ git worktree add -b t3/x ../wt main
fatal: invalid reference: main
Workaround
Make an initial commit, or start the thread in the main checkout.
Prior work
Reacted by BURAKBEY and Charles White Activityjuliusmarminge commented on Oct 21, 2026 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.
juliusmarminge commented on Oct 22, 2026 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.
juliusmarminge commented on Oct 22, 2026 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.
cornishandy commented on Nov 23, 2026 Still happening on nightly 0.1.12-nightly.20261122.5111, and it also breaks scheduled tasks. An unbound task created with the schedule_task MCP tool gets a worktree strategy whose baseRef falls back to main when no branch ref resolves (scheduledTaskWorkspaceStrategy / resolveScheduledTaskBaseRef in OrchestratorMcpService.ts, main 6b38ec9). ScheduledTaskService.upsert only switches that to the project folder for Scratch or non-Git projects, so in a repo with no commits every such task fails when it fires, before the model starts:
Workspace preparation failed during provision worktree: Base ref "main" does not resolve to a commit in project "<project>" (<workspace root>).
This happened to me twice (19 and 22 Nov, in a repo with no commits and no remote). A follow-up message sent to the failed thread then stayed queued without starting.
Unbound scheduled runs go through ThreadLaunchService.launch, so the fallback in #34968 should cover them too (and #39760 would let schedule_task choose the project checkout directly). Until then, binding the task to a thread, or making an initial commit, avoids it.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|