Repository navigation
Open
Labels
coreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLIgh-prrelating to the gh pr commandstaletech-debtA chore that addresses technical debt
Description
Problem
When gh pr create sends invalid ref data to the GitHub GraphQL API, the raw error message surfaces directly to the user:
pull request create failed: GraphQL: Head sha can't be blank, Base sha can't be blank,
No commits between main and <branch>, Head ref must be a branch, Base ref must be a branch
This message is unhelpful because it describes internal API validation failures, not what the user did wrong or how to fix it. There are many different ways users end up here, including:
- Skipping the push step when the branch isn't detected on the correct remote ('gh pr create' fails if skipping pushing with "GraphQL error: Head sha can't be blank, Base sha can't be blank, No commits between master and <branch>, Head ref must be a branch" #2691, 33 👍)
- Passing
remote/branchsyntax to-H/-Binstead ofowner:branch(pr createfails with multiple remotes #12824) - Multi-remote or same-org fork setups confusing remote resolution (gh and REST API unable to work with same-org forked repos #6462)
- Local/remote branch name mismatches (gh pr create assumes that local and remote branch names match #11041)
--headnot handling fork workflows properly (gh pr create --headdoesn't properly handle forked workflow #10448,gh pr create --head ...does not push #11970)@{push}/remote.pushdefaultnot being respected (pr create: respect git@{push}configuration for the current branch #1645, Detect push target for local branches without upstream configuration #575)
In all of these cases, the user sees the same opaque GraphQL error.
Proposed solution
Add some sort of client-side state validation before the createPullRequest mutation is sent, with actionable error messages.
Maybe:
- If
headRefNamecontains a/that matches a known remote name, suggest usingowner:branchsyntax instead - If
baseRefNameresolves to a SHA instead of a branch name, tell the user to pass just the branch name - If the head branch doesn't appear to be pushed to any GitHub remote, say so explicitly and suggest pushing first
- If the mutation fails, wrap the GraphQL error with context about what was sent and common fixes
Goal
Make it easier to understand what might be wrong with the user's input when gh pr create fails.
Related issues
| Issue | Summary |
|---|---|
| #2691 | Skip-push fails when @{upstream} != push remote (33 👍) |
| #1645 | Respect git @{push} config (5 👍) |
| #6462 | Can't work with same-org forked repos (3 👍) |
| #12824 | Fails with multiple remotes (remote-prefixed refs) |
| #11970 | --head doesn't push |
| #11041 | Assumes local and remote branch names match |
| #10448 | --head doesn't handle forked workflow |
| #10238 | Mysterious "no commits between" message |
| #9201 | --dry-run works but actual command does not |
| #6224 | "PR creation fails with a very confusing message" |
| #6864 | Preserve user inputs more defensively (recovery/data loss) |
Reacted by Will Slattum
Metadata
Metadata
Assignees
Labels
coreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLIgh-prrelating to the gh pr commandstaletech-debtA chore that addresses technical debt
Activity
github-actions commentedon Mar 9, 2026
Thank you for your issue! We have categorized it as an enhancement (feature or improvement) 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 wantedContributions 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.