# Error on running agent in a worktree in a remote branch

**URL:** <https://forum.cursor.com/t/error-on-running-agent-in-a-worktree-in-a-remote-branch/154763>\
**Category:** Bug Reports\
**Tags:** worktrees, ssh\
**Created:** [March 14, 2026, 2:15pm UTC](https://forum.cursor.com/t/error-on-running-agent-in-a-worktree-in-a-remote-branch/154763 "2026-03-14T14:15:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vitormariano](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/vitormariano/32/101707_2.png) [@vitormariano](https://forum.cursor.com/u/vitormariano)\
**Post date:** [March 14, 2026, 2:15pm UTC](https://forum.cursor.com/t/error-on-running-agent-in-a-worktree-in-a-remote-branch/154763/1 "2026-03-14T14:15:42Z")

</div>

### Where does the bug appear (feature/product)?

Cursor IDE

### Describe the Bug

The agent hangs forever when I start a chat in a worktree from a remote branch (that’s not available locally). I can fix it manually running `git fetch origin <branch-name>:<branch-name>`.

### Steps to Reproduce

1. Create a remote branch `remote-branch`
2. Start a new chat that will run in a worktree and select `remote-branch` as a base.
3. Ask anything, and Cursor will pop an error `Failed to create Git worktree: Failed to execute git`

### Screenshots / Screen Recordings

 ![image (1).png](https://us1.discourse-cdn.com/cursor1/original/3X/1/2/1223ae95d4b322e1fb3ee85acf0e794402f6a7f4.png)

### Operating System

MacOS

### Version Information

Version: 2.6.13 (Universal)  
VSCode Version: 1.105.1  
Commit: 60faf7b51077ed1df1db718157bbfed740d2e160  
Date: 2026-03-06T06:17:49.499Z  
Build Type: Stable  
Release Track: Default  
Electron: 39.6.0  
Chromium: 142.0.7444.265  
Node.js: 22.22.0  
V8: 14.2.231.22-electron.0  
OS: Darwin arm64 24.6.0

### For AI issues: which model did you use?

Auto

### Additional Information

It’s important to notice that I’m running the IDE through the Remote SSH extension, connected to a Linux server.

### Does this stop you from using Cursor

No - Cursor works, but with this issue

---

<div class="post-metadata">

**Author:** ![deanrie](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/deanrie/32/1263_2.png) [@deanrie](https://forum.cursor.com/u/deanrie)\
**Post date:** [March 14, 2026, 2:42pm UTC](https://forum.cursor.com/t/error-on-running-agent-in-a-worktree-in-a-remote-branch/154763/4 "2026-03-14T14:42:47Z")

</div>

Hey, thanks for the report. This is a bug. The UI shows remote branches without the `origin/` prefix, but when creating a worktree it tries to resolve the bare branch name via `git rev-parse`, which can’t find the ref unless there’s a local copy.

The workaround you found (`git fetch origin <branch>:<branch>`) is currently the only option. It creates a local tracking branch, and then the name resolves correctly.

I’ve passed this to the team. There’s no timeline yet, but your report helps with prioritization.

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/system/32/99069_2.png) [@system](https://forum.cursor.com/u/system)\
**Post date:** [April 5, 2026, 2:44pm UTC](https://forum.cursor.com/t/error-on-running-agent-in-a-worktree-in-a-remote-branch/154763/7 "2026-04-05T14:44:28Z")

</div>

Closed on April 5, 2026, 2:44pm UTC

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.
