You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
gh repo fork --remote does not set a default repository, so gh pr create fails right after forking #14855
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
In a clone with a single remote pointing at someone else's repository, run gh repo fork --remote
Run git push
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
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.
Activity
cli-triage commentedon Oct 28, 2026
This looks like a genuine bug rather than a duplicate. I checked the current
fork.gosource (commit674516f): in the--clonepath, after cloning, the code callsgc.SetRemoteResolution(ctx, upstreamRemote, "base")to mark the parent repo as the default. In theinParent/--remotepath (lines 294-345), the fork remote is added viagitClient.AddRemote, but there is no equivalent call setting a default resolution for the existingupstream/origin-turned-upstream remote. That matches the reporter's observation that--remotenever sets a default while--clonedoes, and explains the subsequentgh pr createfailure.Duplicate check: related issues #8659 ("default repo should be inferred") and #6827 ("default repo tweaks", closed by #7768 which added the
--clonebehavior) 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 linkedhelp wantedissue — this issue appears to be the follow-up providing that context.Suggesting
bug(confirmed via source inspection, clear repro) andgh-repo(command-specific). Priority andhelp wantedare left for a maintainer to assign given the history with #12813.