mislav/hub · error

branch is tracking another local branch

Error message

branch is tracking another local branch

What it means

branchTrackingInformation in commands/pr.go looks up git config branch.<name>.remote and branch.<name>.merge for the current branch. If the configured remote is ".", the branch tracks another LOCAL branch (not a remote), so the function returns this error to signal there is no valid remote tracking setup for creating a pull request.

Source

Thrown at commands/pr.go:410

		}
	}

	filterParams["head"] = headWithOwner

	pulls, err := gh.FetchPullRequests(baseProject, filterParams, 1, nil)
	if err != nil {
		return nil, err
	} else if len(pulls) == 1 {
		return &pulls[0], nil
	} else {
		return nil, fmt.Errorf("no open pull requests found for branch '%s'", headWithOwner)
	}
}

func branchTrackingInformation(branch *github.Branch) (string, *github.Branch, error) {
	branchRemote, err := git.Config(fmt.Sprintf("branch.%s.remote", branch.ShortName()))
	if branchRemote == "." {
		err = fmt.Errorf("branch is tracking another local branch")
	}
	if err != nil {
		return "", nil, err
	}
	branchMerge, err := git.Config(fmt.Sprintf("branch.%s.merge", branch.ShortName()))
	if err != nil {
		return "", nil, err
	}
	trackingBranch := &github.Branch{
		Repo: branch.Repo,
		Name: branchMerge,
	}
	return branchRemote, trackingBranch, nil
}

func findPushTarget(branch *github.Branch) (*github.Branch, *github.Project, error) {
	branchRemote, headBranch, err := branchTrackingInformation(branch)
	if err != nil {

View on GitHub (pinned to 5c547ed804)

Solutions

  1. Stop tracking the local branch and track a remote instead: git branch --set-upstream-to=origin/<branch> <branch>
  2. Or unset the tracking config: git config --unset branch.<branch>.remote and git config --unset branch.<branch>.merge
  3. Push the branch to a remote first (git push -u origin <branch>) then retry

Example fix

# before
$ git config branch.my-feature.remote
.
# after
$ git push -u origin my-feature
$ git config branch.my-feature.remote
origin
Defensive patterns

Strategy: validation

Validate before calling

// shell check before invoking hub
if [ "$(git config branch.$(git rev-parse --abbrev-ref HEAD).remote)" = "." ]; then
  echo "Branch tracks a local branch; set an upstream remote first" >&2; exit 1
fi

Try / catch

// Go caller pattern
remote, merge, err := branchTrackingInformation(branch)
if err != nil && strings.Contains(err.Error(), "tracking another local branch") {
    // fall back to explicit remote, e.g. prompt user or default to "origin"
    remote = "origin"
}

Prevention

When it happens

Trigger: Running a hub 'pr' command (pullRequest/mergePr path via findPushTarget) while git config for the current branch has branch.<name>.remote set to ".", meaning it tracks a sibling local branch.

Common situations: Developers who intentionally set a local branch to track another local branch for convenience, then try to open a PR; branches created with 'git branch --track <new> <local>' or by manually setting remote=. in .git/config.

Related errors


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