Skip to content

gh repo fork --remote does not set a default repository, so gh pr create fails right after forking #14855

Open

Description

@HaraldNordgren

Describe the bug

I had a clone of mesonbuild/meson with a single remote, upstream. To open a PR, I ran gh repo fork --remote, which added my fork as origin, and git push worked. Then gh pr create refused to run because no default repository was set.

Forking took me from one remote to two and left gh unable to pick one, even though the answer is obviously the repository I just forked. The gh repo fork help text even promises it: "The upstream remote will be set as the default remote repository." Only the --clone path does this, though. --remote in an existing clone never sets a default, whether the original remote was already named upstream or origin got renamed to upstream.

The same change was proposed in #12813, where a maintainer asked about the motivation behind it. I have a fix ready.

Affected version

gh version 2.103.3 (2026-10-26)
https://github.com/cli/cli/releases/tag/v2.103.3

Steps to reproduce the behavior

  1. In a clone with a single remote pointing at someone else's repository, run gh repo fork --remote
  2. Run git push
  3. Run gh pr create

Expected vs actual behavior

Expected: when no default is already set, gh repo fork --remote sets the remote for the forked repository as the default, just as --clone does.

Actual: no default is set, and gh pr create fails until I run gh repo set-default by hand.

Logs

$ gh repo fork --remote
✓ Created fork HaraldNordgren/meson
✓ Added remote origin

$ gh pr create --web
X No default remote repository has been set. To learn more about the default repository, run: gh repo set-default --help

Activity

  1. cli-triage commented on Oct 28, 2026

    @cli-triage

    This looks like a genuine bug rather than a duplicate. I checked the current fork.go source (commit 674516f): in the --clone path, after cloning, the code calls gc.SetRemoteResolution(ctx, upstreamRemote, "base") to mark the parent repo as the default. In the inParent/--remote path (lines 294-345), the fork remote is added via gitClient.AddRemote, but there is no equivalent call setting a default resolution for the existing upstream/origin-turned-upstream remote. That matches the reporter's observation that --remote never sets a default while --clone does, and explains the subsequent gh pr create failure.

    Duplicate check: related issues #8659 ("default repo should be inferred") and #6827 ("default repo tweaks", closed by #7768 which added the --clone behavior) cover adjacent ground, but neither is an exact duplicate of this specific --remote-path gap, and #6827 is already closed. PR #12813 attempted a fix but was closed for lacking a linked help wanted issue — this issue appears to be the follow-up providing that context.

    Suggesting bug (confirmed via source inspection, clear repro) and gh-repo (command-specific). Priority and help wanted are left for a maintainer to assign given the history with #12813.

    Generated by Issue Triage (skills-driven) for #14855 · copilot · auto · 46.9 AIC · ⊞ 4.8K · ◷

  2. added
    bug
    gh-repo
    priority-3
    on Nov 2, 2026
  3. removed
    needs-triage
    on Nov 2, 2026
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

    buggh-repopriority-3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions