mislav/hub · error
%s (use `-h <branch>` to specify an explicit pull request he
Error message
%s (use `-h <branch>` to specify an explicit pull request head)
What it means
Same abort path as the 'head branch is the same as base' error: pullRequest wraps the original error with fmt.Errorf("%s\n(use `-h <branch>` ...)") and passes it to utils.Check. This index records the wrapping error whose format string is the hint suffix, printed with the base-branch message above it.
Source
Thrown at commands/pull_request.go:179
if flagPullRequestHead := args.Flag.Value("--head"); flagPullRequestHead != "" {
headProject, head = parsePullRequestProject(headProject, flagPullRequestHead)
}
baseRemote, _ := localRepo.RemoteForProject(baseProject)
if base == "" && baseRemote != nil {
base = localRepo.DefaultBranch(baseRemote).ShortName()
}
if head == "" && trackedBranch != nil {
if !trackedBranch.IsRemote() {
// the current branch tracking another branch
// pretend there's no upstream at all
trackedBranch = nil
} else {
if baseProject.SameAs(headProject) && base == trackedBranch.ShortName() {
e := fmt.Errorf(`Aborted: head branch is the same as base ("%s")`, base)
e = fmt.Errorf("%s\n(use `-h <branch>` to specify an explicit pull request head)", e)
utils.Check(e)
}
}
}
force := args.Flag.Bool("--force")
flagPullRequestPush := args.Flag.Bool("--push")
if head == "" {
if trackedBranch == nil {
utils.Check(currentBranchErr)
if !force && !flagPullRequestPush {
branchRemote, branchMerge, err := branchTrackingInformation(currentBranch)
if err != nil || (baseRemote != nil && branchRemote == baseRemote.Name && branchMerge.ShortName() == base) {
if localRepo.RemoteForBranch(currentBranch, host.User) == nil {
err = fmt.Errorf("Aborted: the current branch seems not yet pushed to a remote")
err = fmt.Errorf("%s\n(use `-p` to push the branch or `-f` to skip this check)", err)
utils.Check(err)View on GitHub (pinned to 5c547ed804)
Solutions
- Run the PR from a differently-named pushed branch
- Use -h <branch> (or <owner>:<branch> for forks) to give an explicit head
- Automations should assert the current branch differs from the base before invoking hub
Example fix
# before hub pull-request -m "msg" # run on main # after hub pull-request -m "msg" -h my-feature
Defensive patterns
Strategy: validation
Validate before calling
branch=$(git rev-parse --abbrev-ref HEAD) [ "$branch" != "$(git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null | sed 's|origin/||')" ] || exit 1
Prevention
- Same as the base error: work on feature branches, not the base branch
- Parse the two-line aborted message in automation and act on the first line
When it happens
Trigger: Identical to error 34: baseProject.SameAs(headProject) && base == trackedBranch.ShortName() when creating a PR — same-repo PR where the head branch name equals the base branch name and -h was not given.
Common situations: Opening a PR from the default branch; scripted PR creation running on 'main' in CI.
Related errors
- Aborted: head branch is the same as base ("%s") (use `-h <br
- could not determine project for head branch
- Aborted: the current branch seems not yet pushed to a remote
- %s (use `-p` to push the branch or `-f` to skip this check)
- Aborted: %d commits are not yet pushed to %s (use `-f` to fo
AI-assisted analysis of mislav/hub@5c547ed804 (2026-09-01).
Data as JSON: /api/errors/cc89a36f3a521a25.
Report an issue: GitHub.