mislav/hub · error
the branch to compare '%s' is the same as --base
Error message
the branch to compare '%s' is the same as --base
What it means
In commands/compare.go compare, after resolving the target branch r (possibly namespaced as owner:branch), it checks whether r equals the --base value. Identical base and compare branches would produce an empty range, so the command fails with "the branch to compare '%s' is the same as --base".
Source
Thrown at commands/compare.go:108
if err != nil {
if remoteProject, err = deducePushTarget(currentBranch, host.User); err == nil {
remoteBranch = currentBranch
} else {
utils.Check(fmt.Errorf("the current branch '%s' doesn't seem pushed to a remote", currentBranch.ShortName()))
}
}
r = remoteBranch.ShortName()
if remoteProject.SameAs(mainProject) {
if flagCompareBase == "" && remoteBranch.IsMaster() {
utils.Check(fmt.Errorf("the branch to compare '%s' is the default branch", remoteBranch.ShortName()))
}
} else {
r = fmt.Sprintf("%s:%s", remoteProject.Owner, r)
}
if flagCompareBase == r {
utils.Check(fmt.Errorf("the branch to compare '%s' is the same as --base", r))
} else if flagCompareBase != "" {
r = fmt.Sprintf("%s...%s", flagCompareBase, r)
}
} else {
if flagCompareBase != "" {
utils.Check(command.UsageError(""))
} else {
r = parseCompareRange(args.RemoveParam(args.ParamsSize() - 1))
if !args.IsParamsEmpty() {
owner := args.RemoveParam(args.ParamsSize() - 1)
mainProject = github.NewProject(owner, mainProject.Name, mainProject.Host)
}
}
}
url := mainProject.WebURL("", "", "compare/"+rangeQueryEscape(r))
args.NoForward()View on GitHub (pinned to 5c547ed804)
Solutions
- Pass a different branch as the compare target than the one given to --base.
- Remove `--base` if you intended the default comparison against the default branch.
- If you meant the three-dot form, choose a distinct base (e.g. --base master with target feature).
Example fix
// before hub compare --base feature-x feature-x // same as --base // after hub compare --base master feature-x
Defensive patterns
Strategy: validation
Validate before calling
// ensure base and target differ before invoking
if flagCompareBase != "" && flagCompareBase == targetBranch {
return fmt.Errorf("--base must differ from the branch to compare")
} Try / catch
if flagCompareBase == r {
return fmt.Errorf("base (%s) equals compare target; pick a different base", r)
} Prevention
- In scripts, assert the two branch variables are not equal
- Remember namespaced targets (owner:branch) compare as full strings
- Review generated hub compare commands in CI logs
When it happens
Trigger: Running `hub compare --base X X` (or a branch that resolves to the same owner:branch string as --base, e.g. same branch name in the same project).
Common situations: Scripting the command with a variable holding the branch name that also got assigned to --base; passing the branch twice by habit; forgetting that bare names on the same repo resolve identically to the --base value.
Related errors
- the branch to compare '%s' is the default branch
- the current branch '%s' doesn't seem pushed to a remote
- Aborted: no revision could be determined from '%s'
- Error: %s/%s doesn't have a wiki
- 'create' must be run from inside a git repository
AI-assisted analysis of mislav/hub@5c547ed804 (2026-09-01).
Data as JSON: /api/errors/f337e57bcb85c591.
Report an issue: GitHub.