Repository navigation
How to change base repo for gh pr? #2300
Description
Activity
- addedcoreThis issue is not accepting PRs from outside contributorsThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLIa request to improve CLIand removedbugSomething isn't workingSomething isn't working
on Oct 27, 2020 @mehagar At this time that is not a feature that
ghsupports. It is a good idea though and we will evaluate if it is something we want to add support for in the future.Reacted by Michael Hagar, Benjamin Chadwick and Linus JahnWhere is this setting stored so we can manually change it?
I have selected the wrong base repository several times.
Perhaps the selection could be more specific base repo for me suggests that I should pick my fork. Where if it asked for upstream repo, I would not question the selection.
Reacted by Kevin R., Dan Kleine (geb. Dan Untenzu), Fleur Kelpin, Steven Elleman, Ajay Mehta, Ruth Chen-Genebach, Adam Sparks, John Bachir, Artur Sinila, Nagual and 9 more- Reacted by David von OheimbReacted by Michael Hagar, Carlos Ortiz , Noah Lev, Jamie Thompson, Romain Niveau (kiva), Kate Donaldson, Maciej Woźniak, Jeff Geerling, Erik Sundell, Dave Clendenan and 80 more
git config --local --get-regexp '.gh-resolved$'
That construction isn't platform portable (because of the single-quotes and shell-specific utilities).
Usegit config --local --unset "remote.origin.gh-resolved"to remove the setting.Reacted by Erick Escriba Arango, Jean Vega, Jugal S, jamesnicolas, Dan Kleine (geb. Dan Untenzu), Isaac Joseph, Carlos Santana, Brad Baker, dugg molidor, Jeremy Harisch and 24 moreReacted by Jean Vega, Carlos Santana, Fleur Kelpin, Joo-On Jung, dugg molidor, tsilavinarazf, Jeremy Harisch, Dervis Avdic, Subin Tom, Nguyễn Văn Huy and 4 moreUse git config --local --unset "remote.origin.gh-resolved" to remove the setting.
This didn't actually work for me, everything was still targeting my fork. The original construction above did work. Would love for an official, discoverable way to do this, as it's very confusing once it ever gets set incorrectly! The prompt for "base repo" is similar to "where should we push this repo", so it's easy to set it wrong.
Reacted by Mislav Marohnić, Erick Escriba Arango, Fleur Kelpin, Bhargav, John Bachir and Daniel D. Beck@henryiii , the configuration key name
remote.origin.gh-resolvedwould be the default/usual one. But, if you named your remote something different, that would alter the needed command. Replacing "origin" with whatever local name that you've given your remote repository and the construction should work. @mislav's construction wipes all the key for all remotes. But, off-hand, I don't know of a way to remove all keys matching a regex from git's config in a cross-platform compatible manner.Reacted by Mislav Marohnić and JanekAhh, so it's an entry inside
.git/config. I'd looked there, but was looking for a section called gh, not an entry under the remotes. Okay, makes much more sense now. Still would love an "official" way to undo a mistake! I constantly answer the first question with where I want to push to, and whenever it was actually asking for the base, that's exactly the wrong answer. And even though seeing the second question immediately lets me realize that I must have answered the first question wrong, if you Control-C out, it's too late, the base is set.Reacted by Jugal S@henryiii Yes, it's inside git's own config. We typically avoid putting gh-related configuration into git, but for this specific case, putting it inside git config meant that the cached bit is preserved even if the repository moves on disk or if its remotes get renamed.
Absolutely, I believe that gh should have a dedicated command to let you undo or change a base repo choice. We'll update this thread once we have something. 👍
Reacted by Jugal SSounds great! Just reverting the change if you control-C out before you finish after answering all the questions but have answered that one question incorrectly would fix it 90% of the time for me. :)
Reacted by kojad666, Jugal S, Oriol Abril-Pla, Jeremy Lenz, Josh Soref and Juan Nunez-Iglesias@henryiii That is actually a great idea. Mind submitting a separate bug report for that? <3
Reacted by Nate SmithIn my opinion we can add this to the doc.
Reacted by RanI appreciate the detail of where this is stored now being described above, and I understand this is a little complex since it's a user setting that one might want to persist with the local clone - but to need to look in the issues for how to change or remove this config setting is rather bad.
If
ghis going to mess with my local.gitthen it should at minimum be documented (in manual, perhaps as a note ingh configoutput, certainly appended to output after being set), and ideally be configurable ingh config. Is that the plan for v1 and v2?For those having trouble getting the right
git config ...invocation: you can just open.git/configin a text editor, find the[remote "USERNAME"]section (where USERNAME is your github username), and removegh-resolved = baseReacted by Billy Tetrud and Ken Kochgit config --edit
Will get you there, too.
Reacted by molleweide, Billy Tetrud, Ken Koch and Theofanis VardatsikosI think that we need a
gh pr resetor another smart way to allow user to correct it. I face this quite often and I will never be able to remember the very long workaround for unconfiguring the current wrong default remote. Maybe even a info text mentioning how to reset it would do?Still 50+ votes and no solution is bad. This clearly indicates that the current experience is bit lacking and that is not an isolated issue.
For the moment I added
alias gh-pr-reset="git config --local --get-regexp '\.gh-resolved$' | cut -f1 -d' ' | xargs -L1 git config --unset"Reacted by Ron Green, Frédéric Harper, Code Hugger (Matthew Jones), Alessia Bellisario and Christoph@ssbarnea If you look there are many PR's related to that, so it's trying to get solved by the community
Reacted by Sorin Sbarneaone and a half year later we are still with the same problem. i edited the
.git/configfile and move thegh-resolved = baseto the correct repo.Reacted by Ron Green, Xavier, Helena Kloosterman, Grzegorz Antoniak, skyler-rs, Joel BERNARD, Russell Banks, MJ Zhang, Oscar D. Hernandez, Christoph and 1 more- added a commit that references this issue
on May 14, 2022 Thanks everyone for your feedback and sorry for the nuisance that was having to edit
.git/configmanually. In the most recent release, there is now thegh repo set-default --unsetcommand for this. Please leave further feedback here #6777Reacted by Xavier, Takakazu Fu, John Bachir, Niklas Wallerstedt, Hiroki Tokunaga and Karthikeyan
Describe the bug
I originally used the
gh pr createcommand, which prompted me to pick a base repo. I picked my forked repo instead of the upstream one, and now I'm unsure how to change the base repo so I don't need to prefix every command with--repo. Is there any way to do this?Steps to reproduce the behavior
gh pr createExpected vs actual behavior
I expected there to be a command like
gh repo setor something that will let me configure what the base repo for pushing should be.Logs