Worktree Creation Fails - "Failed to execute git" with undefined branch

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

When attempting to create a new worktree via Cursor’s worktree UI, it fails with the error notification:

“Failed to create Git worktree: Failed to execute git”

Root Cause (from logs)

The logs reveal that the branch name is not being passed from the UI - it shows as undefined:

From Cursor Indexing & Retrieval.log:

2026-02-02 10:03:58.091 [info] Starting worktree creation with branch: undefined from base: dev from cwd: /Users/ronk/projects/Melian2/Melian2026-02-02 10:03:58.197 [error] Error creating worktree with branch undefined: Failed to execute git

From renderer.log:

2026-02-02 10:03:58.198 [error] [WorktreeManager] Failed to create worktree: Failed to execute git
The branch: undefined causes the git command to fail since undefined is not a valid git reference.

Steps to Reproduce

Open a git repository in Cursor
Click on the worktree creation button in the UI
Error notification appears: “Failed to create Git worktree: Failed to execute git”

Expected Behavior

The branch name entered in the UI should be captured and passed to the git worktree command, creating the worktree successfully.

Operating System

MacOS

Version Information

IDE version: 2.4.27
commit: 4f2b772756b8f609e1354b3063de282ccbe7a690

Additional Information

Log File Locations:
~/Library/Application Support/Cursor/logs/[session]/window1/renderer.log
~/Library/Application Support/Cursor/logs/[session]/window1/exthost/anysphere.cursor-retrieval/Cursor Indexing & Retrieval.log

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

Hey, thanks for the detailed report, it really helps with the diagnosis.

From the logs, it looks like a bug in the UI, the branch name input field isn’t passing the value to the git command (it comes as undefined). I’ll log this to the team.

For now, the workaround is to create a worktree through the terminal:

git worktree add ../my-worktree -b feature/my-branch

A couple of clarifying questions:

  • Which command/button are you using to create the worktree? (Command Palette → which command?)
  • Is this the first time, or has it worked before?
  • Can you try it on a clean repository, does it reproduce?

This is the 2nd time it happens to me (each time it happens - it’s reproduced over and over again for a while and then suddenly it is fixed).
I’m using the Cursor’s New Chat window and switch from “Local” to “Worktree”.
The problem with your suggested workaround is that I want cursor agent to run in the worktree folder and not in the main repo’s folder.
If you have any other suggestion for a workaround it could be super helpful, as I’m using the worktree chats all the time!

I understood the problem - the terminal workaround doesn’t solve it, as the agent is needed specifically in the worktree.

Try this workaround:

  1. Create a worktree through the terminal (as I mentioned above)
  2. Open a new Chat in Cursor
  3. Switch from ‘Local’ to ‘Worktree’ - the already created worktree should appear in the list
  4. Select it - the agent will work in the worktree folder

This should provide the same functionality as creating it through the UI.

Regarding the intermittent nature - that’s an interesting point. Can you notice any pattern when the bug appears/disappears? (restarting Cursor, changing repos, time of day, anything else?) This will help the team with diagnostics.

I’m passing the info to the team - I’ll add your report to the worktree bugs.

No idea. I haven’t noticed any patterns. Sorry.
Would love to hear the team’s updates, Im genuinely curious about the bug and it’s solution.

1 Like