Skip to content

gh pr create with --fill-first fails when head branch exists only remotely #12394

Open

Description

@guludo

Describe the bug

I have an automated workflow where my script pushes a local commit to a new branch in my fork, but it does not create any local branch for such a commit (which is done to keep local references clean).

In that scenario, I'm unable to use gh pr create with the --fill-first flag. I was trying something like below:

gh pr create --head <myuser>:<branch-name> --base <the-base> --R <the-original-repo> --fill-first

But that fails with the following message:

could not compute title or body defaults: failed to run git: fatal: ambiguous argument '<my-fork-remote>/<the-base>...<branch-name>': unknown revision or path not in the working tree.

Does the --fill-first option expect a local branch tracking the remote one to exist? If so, could that be fixed so that gh uses <my-fork-remote>/<branch-name> instead of the local branch in order to get the the title and body from the commit object?

Affected version

Please run gh version and paste the output below.

gh version 2.83.2 (2025-12-10)
https://github.com/cli/cli/releases/tag/v2.83.2

Steps to reproduce the behavior

  1. Push a commit to a new branch on your fork but don't have a local branch for it.
  2. Try to use gh pr create with --fill-first as explained in the description.
  3. See error.

Expected vs actual behavior

A clear and concise description of what you expected to happen and what actually happened.

Logs

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

[git remote -v]
[git config --get-regexp ^remote\..*\.gh-resolved$]
* Request at 2025-12-30 17:27:58.109539028 -0300 -03 m=+0.053550988
* 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: <redacted>
> Content-Length: 534
> Content-Type: application/json; charset=utf-8
> Graphql-Features: merge_queue
> Time-Zone: <redacted>
> User-Agent: GitHub CLI v2.83.2

GraphQL query:
fragment repo on Repository {
    id
    name
    owner { login }
    hasIssuesEnabled
    description
    hasWikiEnabled
    viewerPermission
    defaultBranchRef {
      name
    }
  }

  query RepositoryInfo($owner: String!, $name: String!) {
    repository(owner: $owner, name: $name) {
      ...repo
      parent {
        ...repo
      }
      mergeCommitAllowed
      rebaseMergeAllowed
      squashMergeAllowed
    }
  }
GraphQL variables: {"name":"<fork-repo-name>","owner":"<my-user>"}

< HTTP/2.0 200 OK
< Access-Control-Allow-Origin: *
< Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset
< Content-Security-Policy: default-src 'none'
< Content-Type: application/json; charset=utf-8
< Date: Tue, 30 Dec 2025 20:27:59 GMT
< Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
< Server: github.com
< Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
< Vary: Accept-Encoding, Accept, X-Requested-With
< X-Accepted-Oauth-Scopes: repo
< X-Content-Type-Options: nosniff
< X-Frame-Options: deny
< X-Github-Media-Type: github.v4; param=merge-info-preview.nebula-preview; format=json
< X-Github-Request-Id: <redacted>
< X-Oauth-Client-Id: <redacted>
< X-Oauth-Scopes: gist, read:org, repo
< X-Ratelimit-Limit: 5000
< X-Ratelimit-Remaining: 4959
< X-Ratelimit-Reset: 1767127634
< X-Ratelimit-Resource: graphql
< X-Ratelimit-Used: 41
< X-Xss-Protection: 0

{
  "data": {
    "repository": {
      "id": "<redacted>",
      "name": "<fork-repo-name>",
      "owner": {
        "login": "<my-user>"
      },
      "hasIssuesEnabled": true,
      "description": "<redacted>",
      "hasWikiEnabled": true,
      "viewerPermission": "ADMIN",
      "defaultBranchRef": {
        "name": "master"
      },
      "parent": {
        "id": "<redacted>",
        "name": "<fork-repo-name>",
        "owner": {
          "login": "<redacted>"
        },
        "hasIssuesEnabled": true,
        "description": "<redacted>",
        "hasWikiEnabled": true,
        "viewerPermission": "WRITE",
        "defaultBranchRef": {
          "name": "master"
        }
      },
      "mergeCommitAllowed": true,
      "rebaseMergeAllowed": true,
      "squashMergeAllowed": true
    }
  }
}

* Request took 1.583616141s
[git config --get-regexp ^branch\.<branch-name>\.(remote|merge|pushremote|gh-merge-base)$]
[git -c log.ShowSignature=false log --pretty=format:%H%x00%s%x00%b%x00 --cherry <my-fork-remote>/<the-base>...<branch-name>]
could not compute title or body defaults: failed to run git: fatal: ambiguous argument '<my-fork-remote>/<the-base>...<branch-name>': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

Activity

  1. added
    bug
    on Dec 30, 2025
  2. added
    needs-triage
    on Dec 30, 2025
  3. added
    enhancement
    and removed
    bug
    on Mar 16, 2026
  4. github-actions commented on Mar 16, 2026

    @github-actions
    Contributor

    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 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.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions