Checkout Pull Request in Worktree fails for PRs from forks ("Failed to execute git")
Maintainer antworten meist innerhalb von 1 Tag
@alexr00 arbeitet bereits daran.
Seit 24.9.2026.
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
Bug
"Checkout Pull Request in Worktree" fails with a generic Failed to create worktree: Failed to execute git error whenever the pull request comes from a fork.
Root cause
checkoutPRInWorktree in src/github/worktree.ts always fetches the PR's head branch from the base repo's remote:
const remoteName = pullRequestModel.remote.remoteName;
...
await repositoryToUse.fetch({ remote: remoteName, ref: branchName });
pullRequestModel.remote is the remote for the repository the PR was opened against (typically origin). For a PR opened from a fork, the head branch only exists on the fork's remote/clone URL, not on origin, so the fetch fails with something like:
fatal: couldn't find remote ref <branch-name>
That underlying git error isn't surfaced — it's swallowed into the generic "Failed to execute git" message shown to the user, which makes the bug very hard to diagnose without extension logs.
Note the extension's regular (non-worktree) checkout path already handles this correctly: PullRequestGitHelper.fetchAndCheckout detects isFork (pull.head.repositoryCloneUrl.owner !== pull.base.repositoryCloneUrl.owner) and, when true, calls checkoutFromFork, which creates (or reuses) a remote pointing at the fork's clone URL before fetching. The worktree checkout path bypasses all of this.
Repro steps
- Open a repo where you have
originpointing at the upstream repository. - Open a pull request from a fork (i.e.
head.repo.owner != base.repo.owner) in the Pull Requests view. - Use "Checkout Pull Request in Worktree".
- Observe the notification:
Failed to create worktree: Failed to execute git. - In the Git output channel /
Git.log, the actual command run is:> git fetch origin <fork-branch-name> fatal: couldn't find remote ref <fork-branch-name>
Expected behavior
Worktree checkout should succeed for fork PRs the same way regular checkout does, by fetching from a remote associated with the fork (creating one if necessary) instead of always using the base repo's remote.
Environment
- GitHub Pull Requests extension (recent version, confirmed via extension logs on 2026-09-24)
- VS Code Server (remote/SSH), Linux
Fix
I have a small fix ready and will open a PR shortly that mirrors the existing fork-detection logic from PullRequestGitHelper.fetchAndCheckout/checkoutFromFork inside checkoutPRInWorktree.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 2.6k
- Forks
- 796
- Ø Merge
- 8 Std. 40 Min.
- Gemergte PRs (30 T.)
- 41
Entwicklungsumgebung
Die Einrichtungsdateien dieses Projekts haben wir noch nicht geprüft. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus microsoft/vscode-pull-request-github
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
microsoft/vscode-pull-request-github#8953 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Issue 3 — DocumentationOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
microsoft/vscode-pull-request-github#8792 ·
Maintainer antworten meist innerhalb von 1 Tag
-
doesnt accept ghe signinEvtl. vergeben @TylerLeonhardt hat das vor 2 Tagen übernommen. Offen
microsoft/vscode-pull-request-github#8982 · 1 Kommentar · 2 Reaktionen · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Opening a submodule bump in the PR changes view fails: "Unable to read file ... that is actually a directory"Evtl. vergeben @alexr00 hat das vor 2 Tagen übernommen. Offen
microsoft/vscode-pull-request-github#8981 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
Pressing on the PR link in the agents window doesn't open the browserEvtl. vergeben @kycutler hat das vor 2 Tagen übernommen. Offen
microsoft/vscode-pull-request-github#8980 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in microsoft/vscode-pull-request-github
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
opengovsg/FormSG#10118 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
ai-driven-qa bug claude
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 75/100
linagora/twake-calendar-frontend#1434 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
check:passed streams:add
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
iptv-org/iptv#52824 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 78/100
jaegertracing/jaeger-ui#4512 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area:ide documentation enhancement platform:macos platform:vscode
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 88/100
anthropics/claude-code#97389 ·
Maintainer antworten meist innerhalb von 1 Tag