Repository navigation
Change default remote for gh commands? #383
Description
Activity
The behavior for
pr createis the opposite: my fork is namedorigin, 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)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).
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.
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/configfile and movegh-resolved = baseto the remote that you want to be the default. I couldn't figure out any way to do this via the CLI.Reacted by hitzhangjie, Chris Glazner, Tushar, foamyguy, Rene Saarsoo, Hadas Suliman, Stefan Appelhoff, Marino Hohenheim, Jeff Belina, Tomer Figenblat and 4 moreI found my way here because of the article below. I picked the wrong repo when using
gh repo syncand 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
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
-Rto 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
-Ron 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.