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 set-default should default to using origin remote #9399
Describe the feature or problem you’d like to solve
GitHub CLI requires setting the default repo, but it should just take the git remote origin as the default repo following standard Git convention.
Proposed solution
By taking the git remote origin GitHub CLI will skip one step of forcing the user to have to manually configure the default repo, breaking scripting commands like:
$ gh repo view
X No default remote repository has been set for this directory.
please run `gh repo set-default` to select a default remote repository.
We talked about this and it is a bit more complicated than it looks at first glance. We're going to do a bit of investigating on our end and I'll get back to you.
It would already be awesome if it offered a choice to just run the command, instead of making users manually invoking it.. It's quite an annoying UX detraction right now.
Making gh to silently pick up origin or upstream by default when both exist is not really an option since it's a subjective decision and not all people/organisations use one or another in their usual practice. For common use cases like creating a PR, it's usually the upstream repo, but there are other commands that a user would want to use against their fork. Let alone cases where the user is maintaining a fork.
That's the reason why gh requires users to specify the remote their working against. This is for clarity and to avoid unexpected behaviours, especially since some commands may mutate the data in non-reversible way.
Maybe a global config option?
As I'm seeing @friederbluemle's PR (#12044), a seemingly valid solution could be to introduce a global config option via which the user can specify a remote name (or an ordered list of them) to be used when there's no explicit default has been set. I'm not saying that's what we should do, it's just a nicer experience as opposed to gh silently making decisions. However, it might be a complicated addition given the way gh does repository detection, and it definitely needs to be discussed.
I appreciate @friederbluemle's time and effort on PR #12044, but I'm afraid I'm going to close it since the new config option approach is not yet fully investigated and an open PR means something we have to review. We may reopen it though if we decided that's the right implementation.
Thanks for the clarification and for taking the time to explain your reasoning, @babakks!
That said, I'd like to share a bit of feedback from a user's perspective. As I think you noticed, the change proposed in PR #12044 wasn't about having gh silently assume origin or upstream without user intent - it was an explicit, opt-in configuration to let those of us who consistently follow a conventional workflow avoid repetitive setup across dozens (or hundreds) of repositories.
The proposed repo_default_remote key would have preserved all existing safeguards and precedence while providing an intentional, one-time global choice. It wouldn't introduce ambiguity or risk, since the user must explicitly enable it.
I completely understand wanting to avoid unexpected behavior and silent defaults. Still, this particular feature aimed to make life easier for advanced users who already know what they're doing - those who want to configure a global default and are comfortable opting into that responsibility.
It's a little disappointing to see the PR closed outright rather than left open for collaborative refinement, especially since your own comment acknowledged a global config option as a potentially valid path worth discussion. Hopefully this can be revisited later or reopened for community input - it's a real quality-of-life improvement for many users who follow standard Git conventions and simply prefer "convention over configuration."
While related, the title of this issue suggests to change the out-of-the-box behavior - PR #12044 changes the behavior only after explicit configuration. It's possible this is sufficient for this issue's author (@HariSekhon). Still, it would be great to keep the discussion separate, and hopefully we can continue exploring the config-based approach in #12044.
Thanks again for reviewing and maintaining the project - your time and consideration are truly appreciated.
Thanks for sharing your feedback, @friederbluemle! 🍻 Can you please open up a new issue aiming at the new config option so that we can continue the discussion there? If you do so, please add links your PR and also this issue. 🙏
As of this issue, while I appreciate everyone's engagement here, I believe it's not really an option to make gh silently pick a remote (See #9399 (comment)). So, I'm going to close this as not planned. Please feel free to comment if you think otherwise.
Activity
jtmcg commentedon Aug 2, 2024
We talked about this and it is a bit more complicated than it looks at first glance. We're going to do a bit of investigating on our end and I'll get back to you.
eMPee584 commentedon Feb 7, 2025
It would already be awesome if it offered a choice to just run the command, instead of making users manually invoking it.. It's quite an annoying UX detraction right now.
scarf005 commentedon Apr 18, 2025
in my opinion it should always default to
upstreamif it's a fork, as there was absolutely zero instance i needed to set my fork as default repo.babakks commentedon Nov 4, 2025
Hi everyone! 👋 Thanks for sharing your ideas! 🙏
Making
ghto silently pick uporiginorupstreamby default when both exist is not really an option since it's a subjective decision and not all people/organisations use one or another in their usual practice. For common use cases like creating a PR, it's usually the upstream repo, but there are other commands that a user would want to use against their fork. Let alone cases where the user is maintaining a fork.That's the reason why
ghrequires users to specify the remote their working against. This is for clarity and to avoid unexpected behaviours, especially since some commands may mutate the data in non-reversible way.Maybe a global config option?
As I'm seeing @friederbluemle's PR (#12044), a seemingly valid solution could be to introduce a global config option via which the user can specify a remote name (or an ordered list of them) to be used when there's no explicit default has been set. I'm not saying that's what we should do, it's just a nicer experience as opposed to
ghsilently making decisions. However, it might be a complicated addition given the wayghdoes repository detection, and it definitely needs to be discussed.I appreciate @friederbluemle's time and effort on PR #12044, but I'm afraid I'm going to close it since the new config option approach is not yet fully investigated and an open PR means something we have to review. We may reopen it though if we decided that's the right implementation.
friederbluemle commentedon Nov 7, 2025
Thanks for the clarification and for taking the time to explain your reasoning, @babakks!
That said, I'd like to share a bit of feedback from a user's perspective. As I think you noticed, the change proposed in PR #12044 wasn't about having
ghsilently assume origin or upstream without user intent - it was an explicit, opt-in configuration to let those of us who consistently follow a conventional workflow avoid repetitive setup across dozens (or hundreds) of repositories.The proposed
repo_default_remotekey would have preserved all existing safeguards and precedence while providing an intentional, one-time global choice. It wouldn't introduce ambiguity or risk, since the user must explicitly enable it.I completely understand wanting to avoid unexpected behavior and silent defaults. Still, this particular feature aimed to make life easier for advanced users who already know what they're doing - those who want to configure a global default and are comfortable opting into that responsibility.
It's a little disappointing to see the PR closed outright rather than left open for collaborative refinement, especially since your own comment acknowledged a global config option as a potentially valid path worth discussion. Hopefully this can be revisited later or reopened for community input - it's a real quality-of-life improvement for many users who follow standard Git conventions and simply prefer "convention over configuration."
While related, the title of this issue suggests to change the out-of-the-box behavior - PR #12044 changes the behavior only after explicit configuration. It's possible this is sufficient for this issue's author (@HariSekhon). Still, it would be great to keep the discussion separate, and hopefully we can continue exploring the config-based approach in #12044.
Thanks again for reviewing and maintaining the project - your time and consideration are truly appreciated.
babakks commentedon Nov 7, 2025
Thanks for sharing your feedback, @friederbluemle! 🍻 Can you please open up a new issue aiming at the new config option so that we can continue the discussion there? If you do so, please add links your PR and also this issue. 🙏
As of this issue, while I appreciate everyone's engagement here, I believe it's not really an option to make
ghsilently pick a remote (See #9399 (comment)). So, I'm going to close this as not planned. Please feel free to comment if you think otherwise.