Repository navigation
Allow setting a default push target for pr create #1718
Description
Activity
Thank you for a great addition to my daily workflow (with the cli), but I was confused after the latest update.
Glad to see you already have an issue for it and 👍 for it being per-repository!
Reacted by Mislav Marohnić, Eric Sirianni, shlomo666, jdierkes, Marcin Kłopotek and Philip JagielskiA hybrid of the two: when choosing a push target for the first time, prompt whether to remember it for this repository (and also offer a command to undo or change that decision later).
Reacted by Mislav Marohnić, Ludwik Trammer, Mark Keisler, Eric Sirianni, Yuri Volkov, Jason Stangroome, Andrew Breckenridge, cowlicks, wayne, Raymond Berger and 6 moreFor better issue search results and less duplicates: "Where should we push the ... branch?"
Reacted by Eric Sirianni, Mislav Marohnić, Robert Fletcher, Cyril Ledru, Brian Low, Ola Gjønnes, Tomislav Maricevic, Kars Barendrecht, Joao-Victor-EM, Adam Jones and 1 moreWhat about a cli flag instead of/in addition to the default? That way people can create aliases for the option(s) they want.
For instance I have the alias
cw: pr create -wbecause I like my PRs to be created in a browser.
Similarly I could create a new alias (or modify this one) with the flag to chose the pushing option I want.Reacted by Mark Nielsen, Brian Low, Marcello Teodori, Shlomi Noach, Lachlan Cooper, Mark Francis, Ola Gjønnes, Antoine Maes, Philip Jagielski and Robert MacEachernReacted by Philip JagielskiWhat @patatepartie suggested is what I want from this. Really enjoyed the workflow of running
gh pr create -fand BAM, I have a PR ready. It's a super slick workflow. If I had to add an extra consistent flag with no unique argument to get that workflow back, then 💯 for it!Reacted by Adeodato Simó, Marcin Kłopotek and Ola Gjønnes- addedcoreThis issue is not accepting PRs from outside contributorsThis issue is not accepting PRs from outside contributors
on Oct 7, 2020 Yeah, I echo both @polothy & @jglick. The combination of
- a flag like
gh pr create --upstream/--forkwould be great for non-interactive use - and for interactive use: the behavior of when choosing a push target for the first time, prompt whether to remember it for this repository (and also offer a command to undo or change that decision later)
would be awesome to see. I run
gh pr create -falot as well, and I'm looking forward to having that finish without interaction once this is implementedReacted by Alex Forrow, Philippe Desjardins, Marcin Kłopotek, Marcello Teodori, Haren S, Ron Green, Philip Sahli, zneix, Alex Tsoi, Max Heinritz and 2 more- a flag like
I echo the sentiment above. I'm still running 0.12 because losing my
gh prfalias/workflow is too high of a price for me.Since git config already defines remote.pushDefault to specify which remote to push to by default, and also defines push.default to specify how to push when no refspec is given, it seems reasonable that
pr createshould support respecting these configuration entries if present, rather than introducing a new GitHub-CLI-specific mechanism to achieve the same result.Reacted by David Wessman, Dennis Schridde, Fabio Matos, Jason Karns, Mario Montes, Philippe Blain, Max Heinritz, cowlicks, Ola Gjønnes, Raymond Berger and 10 morerather than introducing a new GitHub-CLI-specific mechanism to achieve the same result
I am not familiar with all the options available in Git here, but one way or another I would want to differentiate
git pushto an existing tracking branch such asorigin/master(e.g. typo fix inREADME.md) fromgh pr create(should always push to my fork).IMHO explicit command line options are better than magic defaults, I would like to be able to use gh pr create in a non interactive way in Travis CI and with the prompt I cannot find a workaround now, happy to learn if any -- basically the equivalent of
hub pull-request --no-edit -p@mteodori My aim is to enable something like that! But until the next feature release that allows this, I would suggest the following approach for scripting/automation:
$ git push -u origin HEAD $ gh pr create --fillReacted by Marcello Teodori, Ron Green, Ryan Meisters, pavol kutaj, Vaibhav Jain, Ville Sebastian Olsson, Blake Erickson, Zeyi Wang, Jack Green and Dmitry BufistovReacted by Alex Tsoi, Garry C, Brian Strauch, Jose Alban, Guneshwor Singh, Vasyl Zuziak and Martin TuróciReacted by Shlomi Noach, Ryan Meisters and CelisI really miss option to avoid this last confirmation. I do want to push always when I create a PR and I would love
gh pr create --fillto be really one-click command. Maybe--push=repoor any settings, whatever, but I'm really annoyed by this extra confirmation =(Reacted by Sorin Sbarnea, Ben Rometsch, Roi Rosenthal, rayx, knightofiam, Paul Johnson, clodal, Édouard Lopez and Philip JagielskiAs mentioned in my issue (which I didn't see this duplicate before)
In the cli for gitlab they have the tooling to do this changeThe solution they proposed is:
glab mr create --fill -yAnd the first time it sets the default push target and pushed there each time
I hope that helps
11 remaining items
is there a workaround to bypass interaction on
gh pr create --fill@mteodori My aim is to enable something like that! But until the next feature release that allows this, I would suggest the following approach for scripting/automation:
$ git push -u origin HEAD $ gh pr create --fill! ~/r/c/Cataclysm check-translations *$… git push -u origin HEAD && gh pr create -w 10.1s 2023년 10월 03일 (화) 오후 10시 47분 00초branch 'check-translations' set up to track 'origin/check-translations'. Everything up-to-date Warning: 5 uncommitted changes ? Where should we push the 'check-translations' branch? [Use arrows to move, type to filter] > cataclysmbnteam/Cataclysm-BN scarf005/Cataclysm-BN Skip pushing the branch Cancelthis solution does not seem to work.
- added a commit that references this issue
on Dec 15, 2023 the solution implemented is a
--headflag
so for example I can do my full automated process like this# notice I just create the branch and I now I'm able to push to this new --head git checkout -b "BOT-Conversor-Migra-SQL-v${maxMajorVersion}.${newMinorVersion}" git commit -am "Update SQL-Scripts [$list_scripts_string]" git push origin "BOT-Conversor-Migra-SQL-v${maxMajorVersion}.${newMinorVersion}" gh pr create -a "Joao-Victor-EM" -b "Migrate to [${maxMajorVersion}.${newMinorVersion}]" -t "SQL Migration v${maxMajorVersion}.${newMinorVersion}" -B hmg --head "BOT-Conversor-Migra-SQL-v${maxMajorVersion}.${newMinorVersion}"
This seems to defeat the entire purpose of the
--fillflag.Weirdly I swear this was working for me last week, but now I am prompted every time. Extremely annoying UX.
The advice to
git push -u origin HEADdoesn't have any effect nor does the advice to use a filter tree instead of a shallow clone.Reacted by Byonghun Lee, 93578237, Kyle Holzinger, Bohdan Frankovskyi, Ian Chamberlain and Dave Landis- added a commit that references this issue
on Mar 15, 2024 Experience report:
For my main work repo I use a script to do pre-PR checks (run longer linter, etc) and then call
gh pr create --fill. Many times I've come back to the terminal where I ran it and found the "which repo?" prompt waiting for me. I always want the first option.I put together danp@093bf98 which adds
--push-repo <remote name | user/repo>. That lets me usegh pr create --fill --push-repo originand it works exactly how I want.I think it ended up pretty similar to @arturhoo's attempt in #8146 but I didn't quite find that until after.
Reacted by Ron Green and cowlicksReacted by Mukund Jalan and Anatole Beuzon- added a commit that references this issue
on Mar 20, 2024 - added a commit that references this issue
on Apr 4, 2024 Experience report:
it seems that the prompt will not appear if you have set a upstream correctly.
I ran
git config --global push.autoSetupRemote true, so every when i push a branch, git will automatically set up the upstream for me.after that when i run
gh pr create --base main --fill --web, the prompt does not show up.I hope it helps whoever stumble into this situation.
(but mind you, you might run into a situation like in #1718 (comment))
Reacted by Todor Andonov, Vasyl Zuziak and Harald NordgrenAs a workaround following #1718 (comment) I am testing
aliases: prfork: '!git push -u fork HEAD && gh pr create "$@"'
(Note that
gh help alias setis not very helpful regarding extra arguments combined with--shellmode.)Reacted by Casper Weiss Bang- added a commit that references this issue
on Jul 19, 2024 Sadly that
git push -u origin HEADis very dangerous, I already pushed to main by mistake on a personal repository. If you ever make the mistake to run from main branch, you may be sorry. I am afraid that a good/safe solution would look far more complex. I am planning to do one but I will likely need a full weekend for that.GitHub rulesets (or the older Branch Protection) are the solution for this.
Reacted by Jason Karns- addedpitchpitched internally for prioritisationpitched internally for prioritisation
on Mar 10, 2026
In #1706 we've changed
pr createso it no longer automatically pushes to a remote, but prompts instead. We made that change because, during beta, we weren't able to find a default that people would be generally satisfied with. Some people always want to push to their fork, some always want to push to the base repo even though they might have a fork, and some want to avoid auto-pushing altogether. Finally, for people working on work or otherwise private projects, it doesn't make sense to ask for a push target because there is usually only one, centralized target.The new change adds an extra step to
pr createthat some people might find tedious and repetitive, especially when they already know up front that they always want to push to the same remote. We could either, or both