Skip to content

pr create: flag to push local branch to remote without prompting #8152

Description

@arturhoo

My workflow with private repositories usually consists of:

  1. Create a new branch locally
  2. Modify code and create commits
  3. Create a PR in the private repository using gh repo create --fill

The vast majority of times, the PR will be created in the base repository as defined by

func (r *ResolvedRemotes) BaseRepo(io *iostreams.IOStreams) (ghrepo.Interface, error) {

In other words, I'm pushing my local branch to the origin remote (the central, private repository) as part of the PR creation flow.

This is currently done through an interactive prompt, where the base repository is presented as the first option - I've created the muscle memory of just pressing <enter> right after running gh pr create every time.

Proposed solution

Implement a new flag that is functionally equivalent of selecting the first option presented in the interactive prompt of pr create when the local branch hasn't been pushed to a remote.

Users who primarily work on private repositories will usually only have a single push target, making the interactive prompt at each PR make less sense.

Alternatives

I can always run git push -u origin HEAD before calling gh pr create. Alternatively, an alias based approach was proposed in #1718 (comment) - gh alias set --shell cpr 'git push -u origin HEAD && gh pr create $*'.

Additional context

This has been previously discussed in:

Creating a new issue at the request of @andyfeller on #8146

Activity

  1. added
    discussFeature changes that require discussion primarily among the GitHub CLI team
    coreThis issue is not accepting PRs from outside contributors
    gh-prrelating to the gh pr command
    and removed
    discussFeature changes that require discussion primarily among the GitHub CLI team
    on Oct 12, 2023
  2. samcoe commented on Oct 17, 2023

    @samcoe
    Contributor

    @arturhoo Thanks for opening this issue and pull request, we appreciate your commitment to improving gh. The team discussed this at length and while we understand the desire to have this feature, at this time we are unwilling to support it. I have added this issue to our larger tracking issue #7575 for the various improvements we want to make to the pr create command. As you can see from the tracking issue there are numerous issues, we want to take a step back and evaluate how best to tackle these issues holistically rather than continuing to build single one-off solutions. As part of this decision I am going to close #8146 but if we do reverse our decision here we will make sure to re-open it to make sure you receive acknowledgement of your contribution 🙇

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

    coreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLIgh-prrelating to the gh pr command

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions