fix: error when head and base refs are identical in pr create by majiayu000 · Pull Request #12376 · cli/cli

@majiayu000

When a user runs `gh pr create` with head and base refs pointing to
the same ref in the same repository, the command now exits with an
error instead of proceeding with an invalid PR creation.

This prevents accidental pushes to the main branch and provides clear
feedback when users attempt to create a PR from the base branch.

Cross-repository PRs (e.g., from forks) with the same branch name
continue to work as expected.

Fixes cli#11903

Signed-off-by: majiayu000 <1835304752@qq.com>

@BagToad

BagToad

@majiayu000

Signed-off-by: majiayu000 <1835304752@qq.com>

tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request

Jan 22, 2026

@tmeijn