Visitar URL original
Use the tracked organization-owned fork as the pull request head · Issue #14511 · cli/cli · GitHub
Skip to content

Use the tracked organization-owned fork as the pull request head #14511

Description

@williammartin

Describe the feature or problem you’d like to solve

An organization can own more than one fork that could supply a pull request branch. An organization and branch alone are therefore not always enough to identify the contributor’s intended head repository.

As a contributor working in an organization with multiple forks, I want to identify the exact head repository, so that the pull request is created from the fork I intended.

Proposed solution

Allow gh pr create --head ORGANIZATION/REPOSITORY:BRANCH to identify the exact organization-owned head repository. When --web is used, translate that value into GitHub’s repository-qualified compare syntax so the pull request form opens with the intended head repository and branch selected.

Feature: Choose a specific organization-owned fork as the pull request head

  Scenario: The selected fork belongs to another organization
    Given the base repository is "org/upstream"
    And "other-org/upstream-fork" is a fork of the base repository
    When the contributor runs `gh pr create --head other-org/upstream-fork:feature-branch`
    Then a pull request is created from "other-org/upstream-fork:feature-branch"
    And the pull request targets "org/upstream"

  Scenario: The selected fork belongs to the same organization as the base repository
    Given the base repository is "org/upstream"
    And "org/upstream-fork" is a fork of the base repository
    When the contributor runs `gh pr create --head org/upstream-fork:feature-branch`
    Then a pull request is created from "org/upstream-fork:feature-branch"
    And the pull request targets "org/upstream"

  Scenario: The organization owns multiple candidate forks
    Given the base repository is "org/upstream"
    And "org/upstream-fork" is a fork of the base repository
    And "org/experimental-upstream-fork" is a fork of the base repository
    When the contributor runs `gh pr create --head org/upstream-fork:feature-branch`
    Then a pull request is created from "org/upstream-fork:feature-branch"
    And the pull request targets "org/upstream"

  Scenario: Repository-qualified head is used with web mode
    Given the base repository is "org/upstream"
    And "other-org/upstream-fork" is a fork of the base repository
    When the contributor runs `gh pr create --head other-org/upstream-fork:feature-branch --web`
    Then GitHub’s pull request form opens for "org/upstream"
    And "other-org/upstream-fork" is selected as the head repository
    And "feature-branch" is selected as the head branch

Additional context

This is a sub-issue of #10093.

GitHub’s compare flow represents an exact fork as OWNER:REPOSITORY:BRANCH. For example, other-org/upstream-fork:feature-branch can be rendered in the compare URL as other-org:upstream-fork:feature-branch.

Supporting evidence:

The syntax is documented for GHES 3.10 and newer. All currently supported GHES versions are newer than that; the exact implementation floor for older, unsupported GHES releases is unknown.

Activity

  1. cli-triage commented on Sep 23, 2026

    @cli-triage

    This is a clear, well-specified enhancement request (one of three sibling sub-issues of #10093, alongside #14510 and #14512), so I found no duplicates. I'm suggesting enhancement and gh-pr labels.

    A concrete starting point for investigation: gh pr create's "skip push" path already resolves the head repo from tracked git remote/branch config via TryDetermineDefaultPRHead, but when building the qualified head ref for the API it only prefixes the owner when headRepo.RepoOwner() != baseRepo.RepoOwner() — see

    qualifiedHeadRef := shared.NewQualifiedHeadRefWithoutOwner(defaultPRHead.BranchName)
    if headRepo.RepoOwner() != baseRepo.RepoOwner() {
    qualifiedHeadRef = shared.NewQualifiedHeadRef(headRepo.RepoOwner(), defaultPRHead.BranchName)
    }
    . Since an organization-owned fork can share the same owner as the upstream repository (the scenario this issue calls out), that owner check fails to distinguish the fork from upstream, so the qualifier gets dropped even though the resolved headRepo correctly points at the fork. That looks like the mechanism this issue wants changed: the qualifier should be based on whether headRepo and baseRepo are the same repository (e.g. ghrepo.IsSame), not merely the same owner.

    Generated by Issue Triage (skills-driven) for #14511 · copilot · auto · 46.1 AIC · ⌖ 2.2 AIC · ⊞ 10.9K · ◷

  2. github-actions commented on Sep 24, 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.

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

    enhancementa request to improve CLIgh-prrelating to the gh pr command

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions