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分
- マージ済み PR(30日)
- 41
環境構築
このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 件 · 担当者 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 が 2 日前に担当しました。 オープン
microsoft/vscode-pull-request-github#8980 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
microsoft/vscode-pull-request-github の issue をすべて見る
似ている issue
-
ADD openalgoオープンtemplate
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
factory-active factory-automatic task-bug-reproduction-success task-identify-harness-labels-done task-identify-issue-type-done
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
bug Needs: Triage :mag:
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
microsoft/fluentui-contrib#671 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
sveltejs/acorn-typescript#150 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100