Skip to content

gh repo set-default should default to using origin remote #9399

Closed as not planned

Description

@HariSekhon

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.

Additional context

Relates to:

#9398

#9149

Activity

  1. added
    enhancement
    on Jul 31, 2024
  2. added
    needs-triage
    on Jul 31, 2024
  3. added
    needs-investigation
    and removed
    needs-triage
    on Aug 2, 2024
  4. jtmcg commented on Aug 2, 2024

    @jtmcg
    Contributor

    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.

  5. added
    core
    on Aug 2, 2024
  6. eMPee584 commented on Feb 7, 2025

    @eMPee584

    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.

  7. self-assigned this
    on Feb 7, 2025
  8. scarf005 commented on Apr 18, 2025

    @scarf005
    Contributor

    in my opinion it should always default to upstream if it's a fork, as there was absolutely zero instance i needed to set my fork as default repo.

  9. removed their assignment
    on Apr 23, 2025
  10. babakks commented on Nov 4, 2025

    @babakks
    Member

    Hi everyone! 👋 Thanks for sharing your ideas! 🙏

    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.

  11. added
    needs-triage
    on Nov 4, 2025
  12. friederbluemle commented on Nov 7, 2025

    @friederbluemle

    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.

  13. babakks commented on Nov 7, 2025

    @babakks
    Member

    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.

  14. removed
    needs-investigation
    needs-triage
    on Nov 7, 2025
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

    coreenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions