Checkout Pull Request in Worktree fails for PRs from forks ("Failed to execute git")
Maintainer thường phản hồi trong vòng 1 ngày
@alexr00 đang làm issue này rồi.
Từ ngày 24/9/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 2.6k
- Fork
- 796
- Merge trung bình
- 8 giờ 40 phút
- Pull request đã merge (30 ngày)
- 41
Chuẩn bị môi trường
Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/vscode-pull-request-github
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/vscode-pull-request-github#8953 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Issue 3 — DocumentationĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
microsoft/vscode-pull-request-github#8792 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
doesnt accept ghe signinCó thể đã có người làm @TylerLeonhardt đã nhận 2 ngày trước. Đang mở
microsoft/vscode-pull-request-github#8982 · 1 bình luận · 2 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Opening a submodule bump in the PR changes view fails: "Unable to read file ... that is actually a directory"Có thể đã có người làm @alexr00 đã nhận 2 ngày trước. Đang mở
microsoft/vscode-pull-request-github#8981 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Pressing on the PR link in the agents window doesn't open the browserCó thể đã có người làm @kycutler đã nhận 2 ngày trước. Đang mở
microsoft/vscode-pull-request-github#8980 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của microsoft/vscode-pull-request-github
Issue tương tự
-
ADD openalgoĐang mởtemplate
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
factory-active factory-automatic task-bug-reproduction-success task-identify-harness-labels-done task-identify-issue-type-done
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
vercel/ai#21528 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug Needs: Triage :mag:
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
microsoft/fluentui-contrib#671 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
sveltejs/acorn-typescript#150 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100