Skip to content

pr checkout <full PR url> should exit if the PR is in a completely different repo #15099

Open

Description

@chuckdries

Describe the feature or problem you’d like to solve

If you're in repo-a, and you run the command gh pr co https://github.com/example/repo-b/pull/1234, it'll check out the tracked contents repo-b in your repo-a working directory even though they're completely different repos.

Proposed solution

This is probably easier said than done, but detect if I pasted the link to a PR in a completely unrelated repo and refuse to check it out (maybe with a flag to force it?). I think easiest way to implement might be: if the repo in the command argument isn't already configured as a remote, check whether it is a fork of any of the configured remotes.

Additional context

I'm jumping between PRs and terminal tabs really frequently these days, I have accidentally pasted the wrong PR URL into my shell and checked out a completely unrelated repo twice now. I know it's user error, but it's also a behavior that I can't really think of a valid use case for.

Activity

  1. cli-triage commented on Nov 18, 2026

    @cli-triage

    Thanks for the clear use case. GitHub CLI 2.105.0 accepts a pull request URL from another repository and does not provide a repository-relationship safety check or override flag. The request is therefore a real gap: when the selected pull request's base repository is unrelated to the current checkout, gh pr checkout can fetch it into the current working tree. A useful guard would distinguish an unrelated repository from the normal fork case while preserving an explicit way to proceed. This is ready to be considered as an enhancement to gh pr checkout.

    Supporting reports

    Generated by issue triage.

  2. added
    enhancement
    gh-pr
    on Nov 18, 2026
  3. github-actions commented on Nov 18, 2026

    @github-actions
    Contributor

    Thank you for your issue! We have categorized it as an enhancement (feature or improvement) request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.

    Unless you see the help wanted Contributions welcome label, we are not currently looking for external contributions for this feature.

    If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.

  4. removed
    needs-triage
    on Nov 18, 2026
  5. chirag-gupta7 commented on Nov 19, 2026

    @chirag-gupta7

    Hi @cli/code-reviewers! I noticed that "gh pr checkout" can check out a PR from an unrelated repository into the current working tree. Would the team consider accepting a repository-relationship safety check, and could you clarify the acceptance criteria and whether this could be marked "help wanted"? I won't start an external PR without that approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgh-pr

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions