Skip to content

gh pr create --head ... does not push #11970

Open

Description

@Vampire

Describe the bug

If I have the newly created branch issue-99 checked out and do gh pr create, I am first asked where to push the branch to and then the PR gets created.
But If I use gh pr create --head issue-99 or gh pr create --head Vampire:issue-99, the CLI requires that the branch is already pushed.

When having the branch checked out it of course makes not much sense to use --head.
But if you for example use Jujutsu VCS around Git, then you usually do not have a branch checked out.
So there it would be nice if using --head would also push the new branch like when not using --head.

Affected version

gh version 2.82.0 (2025-10-15)

Steps to reproduce the behavior

  1. gh pr create --head some-newly-created-branch

Expected vs actual behavior

Expected: Branch is pushed
Actual: pull request create failed: GraphQL: Head sha can't be blank, Base sha can't be blank, No commits between master and some-newly-created-branch, Head ref must be a branch (createPullRequest)

Activity

  1. added
    bug
    on Oct 20, 2025
  2. added
    needs-triage
    on Oct 20, 2025
  3. added and removed
    bug
    on Oct 20, 2025
  4. BagToad commented on Oct 20, 2025

    @BagToad
    Member

    Hey @Vampire, thanks for the issue! ✨

    I believe skipping push when --head is provided is intended. Here is a snippet from the help doc:

    When the current branch isn't fully pushed to a git remote, a prompt will ask where
    to push the branch and offer an option to fork the base repository. Use --head to
    explicitly skip any forking or pushing behavior.

    I don't know much about Jujutsu, but maybe a new flag like --push to always push the branch might also be a solution here?

  5. Vampire commented on Oct 20, 2025

    @Vampire
    Author

    Ah, ok.
    I can of course also push with jj first and then just create the already pushed PR using gh, that's what I did now, just that I then also have to type out --head Vampire:already-pushed-branch and cannot do --head already-pushed-branch.
    But yeah, a --push option might also be handy.

  6. added
    enhancement
    gh-pr
    on Oct 20, 2025
  7. github-actions commented on Oct 20, 2025

    @github-actions
    Contributor

    Thank you for your issue! We have categorized it as a feature request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.

    Unless you see the help wanted Contributions welcome label, we are not currently looking for external contributions for this feature.

    If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.

  8. xnh22q9nw9-jpg commented on Oct 25, 2025

    @xnh22q9nw9-jpg
  9. Vampire commented on Oct 28, 2025

    @Vampire
    Author

    @BagToad actually that it did not push was just half of the problem.
    I now pushed some new branches via JJ first and tried then to do gh pr create -H fix-version-comparison or gh pr create -H fix-version-comparison -B main, but both still failed with

    pull request create failed: GraphQL: Head sha can't be blank, Base sha can't be blank, No commits between main and fix-version-comparison, Head ref must be a branch (createPullRequest)

    So my problem is not only the missing --push option, but also that it does not work to PR from a different branch.
    Only after switching to the intended branch and doing gh pr create I got it working.

  10. BagToad commented on Nov 12, 2025

    @BagToad
    Member

    @Vampire Apologies for the delay! That error message is unfortunate because it seems that's a general error message from the API for various reasons. I know you can get that same error message currently when trying to make a cross org PR sometimes as well 🤔

    The short is that I'm not entirely sure the exact cause in your case. I'd love to review the GH_DEBUG=api gh pr create ... output if you bump into this again.

  11. removed
    needs-triage
    on Feb 17, 2026
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

    enhancementgh-prstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions