Checkout Pull Request in Worktree fails for PRs from forks ("Failed to execute git")
维护者通常 1 天内回复
@alexr00 已经在做这个了。
开始于 2026年9月24日。
评估
这个 Issue 还没有评估数据。
描述
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.
- 主要语言
- TypeScript
- 星标
- 2.6k
- 派生
- 796
- 平均合并
- 8 小时 40 分钟
- 30 天内合并 PR
- 41
环境准备
我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/vscode-pull-request-github 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/vscode-pull-request-github#8953 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
microsoft/vscode-pull-request-github#8792 ·
维护者通常 1 天内回复
-
doesnt accept ghe signin可能已有人在做 @TylerLeonhardt 于 3 天前认领。 未关闭
microsoft/vscode-pull-request-github#8982 · 1 条评论 · 2 个 reaction · 已指派 1 人 ·
维护者通常 1 天内回复
-
Opening a submodule bump in the PR changes view fails: "Unable to read file ... that is actually a directory"可能已有人在做 @alexr00 于 3 天前认领。 未关闭
microsoft/vscode-pull-request-github#8981 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Pressing on the PR link in the agents window doesn't open the browser可能已有人在做 @kycutler 于 3 天前认领。 未关闭
microsoft/vscode-pull-request-github#8980 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 microsoft/vscode-pull-request-github 的全部 Issue
相似的 Issue
-
resources
难度 2/5 1-3 小时 新手友好度 72/100
railmapgen/rmg-palette#2445 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
danielmiessler/LifeOS#2242 ·
维护者通常 5 天内回复
-
good first issue hacktoberfest help wanted translation
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
callstackincubator/appduct#129 ·
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 88/100