Checkout Pull Request in Worktree fails for PRs from forks ("Failed to execute git")
Mantenedores costumam responder em até 1 dia
@alexr00 já está trabalhando nisso.
Desde 24/9/2026.
Avaliação
Esta issue ainda não foi avaliada.
Descrição
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.
- Linguagem predominante
- TypeScript
- Estrelas
- 2.6k
- Forks
- 796
- Merge médio
- 8h 13min
- PRs com merge (30d)
- 34
Preparar o ambiente
Ainda não verificamos os arquivos de configuração deste projeto. Comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de microsoft/vscode-pull-request-github
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
microsoft/vscode-pull-request-github#8953 ·
Mantenedores costumam responder em até 1 dia
-
Issue 3 — DocumentationAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
microsoft/vscode-pull-request-github#8792 ·
Mantenedores costumam responder em até 1 dia
-
doesnt accept ghe signinTalvez já em andamento @TylerLeonhardt assumiu há 4 dias. Aberta
microsoft/vscode-pull-request-github#8982 · 1 comentário · 2 reações · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Opening a submodule bump in the PR changes view fails: "Unable to read file ... that is actually a directory"Talvez já em andamento @alexr00 assumiu há 4 dias. Aberta
microsoft/vscode-pull-request-github#8981 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Pressing on the PR link in the agents window doesn't open the browserTalvez já em andamento @kycutler assumiu há 4 dias. Aberta
microsoft/vscode-pull-request-github#8980 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
Todas as issues de microsoft/vscode-pull-request-github
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
microsoft/vscode-livepreview#876 ·
Mantenedores costumam responder em até 1 dia
-
needs-triage
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
JustJarethB/invoicer#54 ·
-
ICP 1.2.0 shows a scheduled task's interval in milliseconds under the label "Interval (In seconds)"AbertaNeeds Triage Type/Bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
wso2/product-integrator#2585 ·
Mantenedores costumam responder em até 1 dia
-
Add: Telemundo West sdAbertacheck:passed streams:add
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia
-
design
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
MTES-MCT/monitor-field#119 ·
Mantenedores costumam responder em até 1 dia