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 於 2 天前認領。 未關閉
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 於 2 天前認領。 未關閉
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
-
module-request
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 90/100
appandflow/stim#1604 · 1 則留言 ·
維護者通常 1 天內回覆
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
難度 1/5 1 小時以內 新手友好度 92/100
lingdojo/kana-dojo#31060 · 1 則留言 · 5 個 reaction ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 90/100
paperclipai/paperclip#14173 ·
維護者通常 1 天內回覆
-
needs-triage
難度 2/5 1-3 小時 新手友好度 85/100
維護者通常 1 天內回覆