Skip to content

gh pr create fails with mysterious "no commits between main and branch" message. #10238

@jacob-keller

Description

@jacob-keller

Describe the bug

I am attempting to create a pull request using the gh cli tool and I now seem to get the following error:

Head sha can't be blank, Base sha can't be blank, No commits between main and branch, Head ref must be a branch (createPullRequest)
gh version 2.65.0 (2025-01-06)
https://github.com/cli/cli/releases/tag/v2.65.0

I recently was told by my $DAYJOB that we needed to move from forks being in our personal namespace to using the internal work namespace. I setup a new fork using

gh repo fork --org sandbox --fork-name personal.jekeller.repo

I then tried to create a new pull request with gh pr create. It asked where I want to push changes, so I chose the new fork in the sandbox namespace.

I proceeded to fill out the PR information as normal, but then see the following (repo/branch names anonymized):

? Where should we push the 'branch' branch? sandbox/personal.jekeller.repo

Creating pull request for sandbox:branch into main in innersource/repo

? Title (required) ice: stop duplicating devlink_fmsg_put macro
? Body <Received>
? What's next? Submit
remote:
remote:
To https://github.com/sandbox/personal.jekeller.repo.git
 * [new branch]                HEAD -> branch
branch 'branch' set up to track 'fork/branch'.
pull request create failed: GraphQL: Head sha can't be blank, Base sha can't be blank, No commits between innersource:main and sandbox:branch, Head ref must be a branch (createPullRequest)

I tried running this in --dry-run to get more info:

Would have created a Pull Request with:
Title: commit message title
Draft: false
Base: main
Head: branch
MaintainerCanModify: true
Body:

Logs

I've attached the output of gh pr create with GH_DEBUG=api in case that helps, though I sleuthed through it and did not see anything obvious. I did my best to redact the sensitive information, but hopefully that didn't ruin the log file.

gh-pr-create-bug.txt

This happened to be once and then mysteriously went away, but came back the next PR I tried to create. Any help understanding what is wrong would be good. I don't know why it stopped, and I have not had issues creating the PRs manually from the web interface.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggh-prrelating to the gh pr commandneeds-triageneeds to be reviewedneeds-user-input

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions