mislav/hub · error

Aborted: no commits detected between %s and %s

Error message

Aborted: no commits detected between %s and %s

What it means

With `--no-edit`, gh skips the interactive editor and derives the PR title/body from the commit log between baseTracking and head. If `git.RefList` finds zero commits in that range, there is no source text for the PR, so it aborts with this error instead of opening an empty PR.

Source

Thrown at commands/pull_request.go:269

	flagPullRequestMessage := args.Flag.AllValues("--message")
	flagPullRequestEdit := args.Flag.Bool("--edit")
	flagPullRequestIssue := args.Flag.Value("--issue")
	if !args.Flag.HasReceived("--issue") && args.ParamsSize() > 0 {
		flagPullRequestIssue = parsePullRequestIssueNumber(args.GetParam(0))
	}

	if len(flagPullRequestMessage) > 0 {
		messageBuilder.Message = strings.Join(flagPullRequestMessage, "\n\n")
		messageBuilder.Edit = flagPullRequestEdit
	} else if args.Flag.HasReceived("--file") {
		messageBuilder.Message, err = msgFromFile(args.Flag.Value("--file"))
		utils.Check(err)
		messageBuilder.Edit = flagPullRequestEdit
	} else if args.Flag.Bool("--no-edit") {
		commits, _ := git.RefList(baseTracking, head)
		if len(commits) == 0 {
			utils.Check(fmt.Errorf("Aborted: no commits detected between %s and %s", baseTracking, head))
		}
		message, err := git.Show(commits[len(commits)-1])
		utils.Check(err)
		messageBuilder.Message = message
	} else if flagPullRequestIssue == "" {
		messageBuilder.Edit = true

		headForMessage := headTracking
		if flagPullRequestPush {
			headForMessage = head
		}

		message := ""

		commits, _ := git.RefList(baseTracking, headForMessage)
		if len(commits) == 1 {
			message, err = git.Show(commits[0])
			utils.Check(err)

View on GitHub (pinned to 5c547ed804)

Solutions

  1. Commit changes on the head branch so at least one commit exists between base and head, then rerun with --no-edit.
  2. Run `gh pr create` without --no-edit and write the title/body in the editor.
  3. Verify the range with `git log <base>..<head>` and check the base branch spelling (`--base <branch>`).

Example fix

// before
gh pr create --base main --no-edit   # no commits ahead of main
// after
git commit -m "Add feature"
gh pr create --base main --no-edit
Defensive patterns

Strategy: validation

Validate before calling

commits, err := git.RefList(base, head)
if err != nil || len(commits) == 0 {
    return fmt.Errorf("no commits between %s and %s; commit changes or drop --no-edit", base, head)
}

Prevention

When it happens

Trigger: `gh pr create --no-edit` where `git.RefList(baseTracking, head)` returns no commits — the head branch has no commits ahead of the base branch (or the ref names resolve to nothing).

Common situations: Creating a PR from a branch that is already merged or identical to base; typo'd base branch name; user assumed --no-edit would reuse a previous PR description; forgetting to commit before creating the PR.

Related errors


AI-assisted analysis of mislav/hub@5c547ed804 (2026-09-01). Data as JSON: /api/errors/1799d7c86c603444. Report an issue: GitHub.