Skip to content

[Bug]: New worktree threads fail in a repository with no commits #22017

Open

Description

@Project516

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

  1. Run git init in an empty folder. Do not commit anything.
  2. Add the folder as a project in T3 Code.
  3. Set new threads to start in a new worktree (Settings, or the project's default).
  4. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions