Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Checkout Pull Request in Worktree fails for PRs from forks ("Failed to execute git")

Ouverte
#8,983 0 commentaires 0 réactions 1 personne assignée Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@alexr00 y travaille déjà.

Depuis le 24/9/2026.

Évaluation

Cette issue n'a pas encore été évaluée.

Description

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

  1. Open a repo where you have origin pointing at the upstream repository.
  2. Open a pull request from a fork (i.e. head.repo.owner != base.repo.owner) in the Pull Requests view.
  3. Use "Checkout Pull Request in Worktree".
  4. Observe the notification: Failed to create worktree: Failed to execute git.
  5. 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.

Langage dominant
TypeScript
Étoiles
2.6k
Forks
796
Merge moyen
8 h 40 min
PR mergées (30 j)
41

Préparer son environnement

Nous n'avons pas encore vérifié les fichiers d'installation de ce projet. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de microsoft/vscode-pull-request-github

Toutes les issues de microsoft/vscode-pull-request-github

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.