Skip to content

gh pr create does not work on remote branches #5465

@dgeelen-uipath

Description

@dgeelen-uipath

Describe the bug

I would expect to be able to create a PR for a remote branch. My use case is that I have a branch, which has some 'local' commits on top that are not pushed to the remote repository (and I don't want to push them). So my branch looks like this:

my_branch        > commit 1
                   commit 2
origin/my_branch > commit 3
                   commit 4
                   commit 5
origin/master    > commit 6

In the web interface I can now create a PR based on commit 3 (origin/my_branch). But when I try to do this from the command line, gh complains that: pull request create failed: GraphQL: Head sha can't be blank, Base sha can't be blank, No commits between origin/master and origin/my_branch, Head ref must be a branch, Base ref must be a branch (createPullRequest)

Possibly related issues: #5290, #5075, #1985 (maybe others?)

$ gh --version
gh version 2.8.0 (2022-04-13)
https://github.com/cli/cli/releases/tag/v2.8.0

Steps to reproduce the behavior

  1. Create branch state as above
  2. Type this 'gh pr create --assignee '@me' --head origin/my_branch --base origin/master --body "hello" --title "bug"'
  3. View the output and see that both the --head and the --base specifications are valid branches (they're just remote).
  4. See error

Expected vs actual behavior

Expected: PR is created
Actual: Error is printed, no PR created

Logs

Paste the activity from your command line. Redact if needed.

$ gh pr create --assignee '@me' --head --head origin/my_branch --base origin/master --body "hello" --title "bug"
Warning: 1 uncommitted change
Creating draft pull request for origin/my_branch into origin/master in Organisation/Project
pull request create failed: GraphQL: Head sha can't be blank, Base sha can't be blank, No commits between origin/master and origin/my_branch, Head ref must be a branch, Base ref must be a branch (createPullRequest)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions