Repository navigation
Description
Describe the bug
gh pr create fails to create PRs in multi-remote scenarios under annoyingly common circumstances.
I have three remotes: a main public repository (upstream), my public fork (external), and a private internal fork (origin) on internal infra. My workflow is to create my branch and push to origin, and when ready create a PR from external into origin.
My repositories currently look like this:
* 4bea964401 (HEAD -> t/disable-error-states, origin/t/disable-error-states, external/t/disable-error-states) Adding release note
* 7fb118f914 Disabling errors states, and documenting why.
* 09206b24d7 (upstream/develop, origin/develop, origin/HEAD, external/develop) Build(deps-dev): bump org.apache.maven.plugins:maven-gpg-plugin from 3.1.0 to 3.2.8 in /modules/db (#7426)
When I run something like gh pr create --title "Disable error states by default" --label maintenance -H external/t/disable-error-states -R opencast/opencast -B upstream/develop I get the wonderfully unhelpful error:
pull request create failed: GraphQL: Head sha can't be blank, Base sha can't be blank, No commits between upstream/develop and external/t/disable-error-states, Head ref must be a branch, Base ref must be a branch (createPullRequest)
As we can see above, there are in fact commits between upstream/develop and external/t/disable-error-states. The error message is unclear whether the Base and Head refs needs to be a sha, or a branch, however neither work.
Further annoyance: Encountering this error completely destroys the (hopefully very nice) PR description you have written up with no recovery.
Affected version
gh version 2.87.3 (2026-02-23)
https://github.com/cli/cli/releases/tag/v2.87.3
Steps to reproduce the behavior
- Create three repos, one not on GH infra. Ensure all three are in the same state.
- Create a branch, push it to 1 of the GH repos, and the third repo.
- Attempt to create a PR between the two GH repos
Expected vs actual behavior
A PR should be created, and failing to create the PR should not destroy the PR description.
Logs
Paste the activity from your command line. Redact if needed.
* Request to https://api.github.com/graphql
> POST /graphql HTTP/1.1
> Host: api.github.com
> Accept: application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview
> Authorization: token [redact]
> Content-Length: 1660
> Content-Type: application/json; charset=utf-8
> Graphql-Features: merge_queue
> Time-Zone: America/Regina
> User-Agent: GitHub CLI 2.87.3
> X-Github-Api-Version: 2022-11-28
GraphQL query:
mutation PullRequestCreate($input: CreatePullRequestInput!) {
createPullRequest(input: $input) {
pullRequest {
id
url
}
}
}
GraphQL variables: {"input":{"baseRefName":"09206b24d7c585fef0e19c30056f9ab48e99ba00","body":"This PR disables service error states by default, as discussed in the developer meeting at Manchester. This PR also adds document
ation around when you migth need these states. Does this need additional markdown docs, if so where?\n\n### Your pull request should…\n\n* [x] have a concise title\n* [ ] ~[close an accompanying issue](https://docs.opencast
.org/develop/developer/#participate/development-process/#automatically-closing-issues-when-a-pr-is-merged) if one exists~\n* [x] [be against the correct branch](https://docs.opencast.org/develop/developer/development-process
#acceptance-criteria-for-patches-in-different-versions)\n* [ ] ~include migration scripts and documentation, if appropriatex\n* [x] pass automated tests\n* [x] have a clean commit history\n* [x] [have proper commit messages
(title and body) for all commits](https://medium.com/@steveamaza/e028865e5791)\n* [ ] ~explain why it needs to be merged into the legacy branch, if it is targeting the legacy branch~\n* [x] include a [release note](https://d
ocs.opencast.org/develop/developer/#participate/development-process/#release-notes) if a feature, or supports a feature (ie, backend part of a frontend feature)\n","draft":false,"headRefName":"external/t/disable-error-states
","maintainerCanModify":true,"repositoryId":"MDEwOlJlcG9zaXRvcnkxMTUxOTg2ODc=","title":"Disable error states by default"}}
⢿< HTTP/2.0 200 OK
[snip]
< X-Xss-Protection: 0
{
"data": {
"createPullRequest": {
"pullRequest": null
}
},
"errors": [
{
"type": "UNPROCESSABLE",
"path": [
"createPullRequest"
],
"locations": [
{
"line": 3,
"column": 4
}
],
"message": "Head sha can't be blank, Base sha can't be blank, No commits between 09206b24d7c585fef0e19c30056f9ab48e99ba00 and external/t/disable-error-states, Head ref must be a branch, Base ref must be a branch"
}
],
"extensions": {
"warnings": [
{
"type": "DEPRECATION",
"message": "The id MDEwOlJlcG9zaXRvcnkxMTUxOTg2ODc= is deprecated. Update your cache to use the next_global_id from the data payload.",
"data": {
"legacy_global_id": "MDEwOlJlcG9zaXRvcnkxMTUxOTg2ODc=",
"next_global_id": "R_kgDOBt3K3w"
},
"link": "https://docs.github.com"
}
]
}
}
* Request took 399.561745ms
pull request create failed: GraphQL: Head sha can't be blank, Base sha can't be blank, No commits between 09206b24d7c585fef0e19c30056f9ab48e99ba00 and external/t/disable-error-states, Head ref must be a branch, Base ref must be a branch (createPullRequest)
Activity
BagToad commentedon Mar 9, 2026
Thanks for the report, @gregorydlogan. I think the issue here is that the
-Hand-Bflags expect branch names (orowner:branchfor cross-repo PRs), notremote/branchgit refs.In your command:
-B upstream/developis being resolved locally as a git ref to a commit SHA, and-H external/t/disable-error-statesis sent literally (including the remote name), neither of which the API understands.What you likely want is:
Where
-Bis just the branch name on the target repo, and-Huses theowner:branchsyntax to tell GitHub which fork the head branch lives on.I agree that error message is poor. It is the result of a complex sequence of events that result in failed lookups in one place or the other, and results in missing data being sent to the mutation and it is rejected. I think we need to spend some time eventually on improving validation and error messaging when validation fails for whatever reason. I've opened #12889 to track that.
Also, re: data loss when this fails, #6864 tracks improving the
--recoverbehavior to preserve user inputs more defensively.BagToad commentedon Mar 9, 2026
Also I'll close this out in favour of those issues, but let me know if I misunderstood please 🙏
gregorydlogan commentedon Mar 13, 2026
tyvm, I figured this was a documentation issue as much as anything. Adding the GH username instead of the remote name does the trick!