mislav/hub · error

Aborted: %d commits are not yet pushed to %s (use `-f` to fo

Error message

Aborted: %d commits are not yet pushed to %s
(use `-f` to force submit a pull request anyway)

What it means

Before submitting a pull request, pullRequest uses git.RefList(trackedBranch.LongName(), "") to count commits on the tracked branch that are not yet on the remote. If there are unpushed commits and -f was not passed, hub aborts with this message telling how many commits are pending and where. This index (38) is the base abort message.

Source

Thrown at commands/pull_request.go:218

			}
			head = currentBranch.ShortName()
		} else {
			head = trackedBranch.ShortName()
		}
	}

	if headRepo, err := client.Repository(headProject); err == nil {
		headProject.Owner = headRepo.Owner.Login
		headProject.Name = headRepo.Name
	}

	fullBase := fmt.Sprintf("%s:%s", baseProject.Owner, base)
	fullHead := fmt.Sprintf("%s:%s", headProject.Owner, head)

	if !force && trackedBranch != nil {
		remoteCommits, err := git.RefList(trackedBranch.LongName(), "")
		if err == nil && len(remoteCommits) > 0 {
			err = fmt.Errorf("Aborted: %d commits are not yet pushed to %s", len(remoteCommits), trackedBranch.LongName())
			err = fmt.Errorf("%s\n(use `-f` to force submit a pull request anyway)", err)
			utils.Check(err)
		}
	}

	messageBuilder := &github.MessageBuilder{
		Filename: "PULLREQ_EDITMSG",
		Title:    "pull request",
	}

	baseTracking := base
	headTracking := head

	remote := baseRemote
	if remote != nil {
		baseTracking = fmt.Sprintf("%s/%s", remote.Name, base)
	}
	if remote == nil || !baseProject.SameAs(headProject) {

View on GitHub (pinned to 5c547ed804)

Solutions

  1. Push the pending commits: git push (or git push -u origin <branch>)
  2. Pass -f / --force to hub pull-request to submit anyway
  3. Verify with git log @{u}..HEAD what is unpushed before deciding

Example fix

# before
$ git log origin/my-feature..HEAD  # 2 commits ahead, then hub pull-request aborts
# after
$ git push
$ hub pull-request
Defensive patterns

Strategy: validation

Validate before calling

branch=$(git rev-parse --abbrev-ref HEAD)
if [ -n "$(git rev-list @{u}..HEAD 2>/dev/null)" ]; then
  git push || { echo "Unpushed commits remain"; exit 1; }
fi

Prevention

When it happens

Trigger: Running hub pull-request with a tracked upstream branch where git.RefList returns >0 local-only commits, without the --force/-f flag.

Common situations: Amending or adding commits after the last push and forgetting to push; network failures earlier left pushes incomplete; automation created commits locally before PR creation.

Related errors


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