Skip to content

pr create fails when local branch name differs from upstream #12800

Open

Description

@jasonkarns

Describe the bug

pr-create seems to fail if the branch has an explicit upstream whose name differs from the local name.

Affected version

$ gh version
gh version 2.86.0 (2026-01-21)
https://github.com/cli/cli/releases/tag/v2.86.0

Steps to reproduce the behavior

  1. local branch: db-migrations-squash-prep
  2. branches upstream: origin/db-migrations-squash
  3. branch is already pushed
  4. ran gh pr create --fill-verbose

Expected vs actual behavior

I expected it to open a PR with the upstream branch origin/db-migrations-squash as HEAD and origin/master as BASE; using the contents of all the commit messages as the PR body.

Instead, I got an error:

could not compute title or body defaults: failed to run git: fatal: ambiguous argument 'origin/master...db-migrations-squash': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

Logs

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

$ GH_DEBUG=true gh pr create --fill-verbose
[git remote -v]
[git config --get-regexp ^remote\..*\.gh-resolved$]
* Request at 2026-02-27 14:39:09.636374 -0500 EST m=+0.057064001
* Request to https://api.github.com/graphql
* Request took 378.510916ms
[git status --porcelain]
[git symbolic-ref --quiet HEAD]
[git config --get-regexp ^branch\.db-migrations-squash-prep\.(remote|merge|pushremote|gh-merge-base)$]
[git rev-parse --symbolic-full-name db-migrations-squash-prep@{push}]
[git show-ref --verify -- HEAD refs/remotes/origin/db-migrations-squash]
[git -c log.ShowSignature=false log --pretty=format:%H%x00%s%x00%b%x00 --cherry origin/master...db-migrations-squash]
could not compute title or body defaults: failed to run git: fatal: ambiguous argument 'origin/master...db-migrations-squash': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

Related

I think these may be related?

Activity

  1. added
    bug
    on Feb 27, 2026
  2. changed the title [-]`pr create` fails to construct PR message[/-] [+]`pr create` fails when local branch name differs from upstream[/+] on Feb 27, 2026
  3. jasonkarns commented on Feb 27, 2026

    @jasonkarns
    Author

    I renamed the remote (upstream) branch name to match the local one, and then the command worked.

    gh-cli should not be making the assumption that the local and remote ref names match. Indeed, git is already aware of the explicit tracking upstream. So gh should be respecting that.

  4. babakks commented on Mar 9, 2026

    @babakks
    Member

    Thanks for reporting this, @jasonkarns! 🙏

    This is a known issue. We've been tracking it in #11503 and I have a draft fix in #11844 that aims to preserve the existing upstream tracking ref when gh pr create pushes the branch, rather than overwriting it with the local branch name.

    That said, it's not a straightforward fix, as I vaguely remember some issues when I was testing the PR, which I had to put aside in favour of other priorities.

  5. added
    priority-3
    core
    gh-pr
    and removed
    needs-triage
    on Mar 9, 2026
  6. babakks commented on Mar 9, 2026

    @babakks
    Member

    I didn't mark it as a duplicate, though, since there maybe difference here.

  7. added a commit that references this issue on Mar 12, 2026
    3a895d5
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

    bugcoregh-prpriority-3stale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions