Skip to content

Change default remote for gh commands? #383

Description

@lgritz

Describe the feature or problem you’d like to solve

A common workflow is to fork a project, commit your proposed changes as a branch in your fork, and submit PR from your fork to the parent project. Usually this means that locally you will have a repo where "origin" is your fork on GH, and there is another remote that is the parent project.

But of course, all the issues and PRs you care about will be for the parent, not for your fork.

You could use -R to specify another remote, every time you use the gh command, but this is a burden on users and very easy to forget or make errors.

So it would be great if there were some kind of persistent per-repo preference that would make all gh commands in that repo refer to a particular remote, rather than "origin," so you don't have to remember to use the -R on all commands.

Does this already exist?

Proposed solution

If it doesn't exist, this would be a great addition, saves lots of potential user mistakes.

Activity

  1. electrum commented on Feb 13, 2020

    @electrum

    The behavior for pr create is the opposite: my fork is named origin, but it pushes the PR branch to the parent repository. (I'd like it to create branches in my fork, even I can write to the parent)

  2. lgritz commented on Feb 13, 2020

    @lgritz
    Author

    Maybe what I want is a little more subtle than I first said. If I say "gh issue list", I want it to list the issues in the parent, not my fork (to which no issues should ever be filed). If I push a PR, I want the branch pushed to my fork, but the PR made against the parent, if you know what I mean.

    Really, it ought to be able to tell which of the remotes is the parent (regardless of their names) and then just do the obvious thing by default (issues and PRs always refer to the parent, but pushed branches should always go to the fork that you own).

  3. mislav commented on Feb 19, 2020

    @mislav
    Contributor

    We are planning improvements around this area! Thank you for your feedback.

    Loosely related: #439 #350

  4. billygriffin commented on Mar 2, 2020

    @billygriffin
    Contributor

    We were initially thinking that a per repo preference also made the most sense, but after thinking through it a bit more I think we may have just gotten the defaults backward. I think the behavior I described in #350 (comment) mirrors what you laid out @lgritz, so I'm going to close this in favor of #350 if there's further discussion.

  5. benmoss commented on Nov 17, 2021

    @benmoss

    If anyone else ends up here like I did because you want to switch from one remote to another as the implicit default (no -R), you can edit your .git/config file and move gh-resolved = base to the remote that you want to be the default. I couldn't figure out any way to do this via the CLI.

    #1864

  6. jbelina commented on Sep 27, 2022

    @jbelina

    I found my way here because of the article below. I picked the wrong repo when using gh repo sync and couldn't figure out how to undo or switch the setting.

    source: https://dev.to/utsavladani/how-to-change-base-repo-in-github-cli-5fhp

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 CLI

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions