{"record":{"id":"ec799e8008990b2d","repo":"mislav/hub","slug":"branch-is-tracking-another-local-branch","errorCode":null,"errorMessage":"branch is tracking another local branch","messagePattern":"branch is tracking another local branch","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/pr.go","lineNumber":410,"sourceCode":"\t\t}\n\t}\n\n\tfilterParams[\"head\"] = headWithOwner\n\n\tpulls, err := gh.FetchPullRequests(baseProject, filterParams, 1, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t} else if len(pulls) == 1 {\n\t\treturn &pulls[0], nil\n\t} else {\n\t\treturn nil, fmt.Errorf(\"no open pull requests found for branch '%s'\", headWithOwner)\n\t}\n}\n\nfunc branchTrackingInformation(branch *github.Branch) (string, *github.Branch, error) {\n\tbranchRemote, err := git.Config(fmt.Sprintf(\"branch.%s.remote\", branch.ShortName()))\n\tif branchRemote == \".\" {\n\t\terr = fmt.Errorf(\"branch is tracking another local branch\")\n\t}\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\tbranchMerge, err := git.Config(fmt.Sprintf(\"branch.%s.merge\", branch.ShortName()))\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\ttrackingBranch := &github.Branch{\n\t\tRepo: branch.Repo,\n\t\tName: branchMerge,\n\t}\n\treturn branchRemote, trackingBranch, nil\n}\n\nfunc findPushTarget(branch *github.Branch) (*github.Branch, *github.Project, error) {\n\tbranchRemote, headBranch, err := branchTrackingInformation(branch)\n\tif err != nil {","sourceCodeStart":392,"sourceCodeEnd":428,"githubUrl":"https://github.com/mislav/hub/blob/5c547ed804368763064e51f3990851e267e88edd/commands/pr.go#L392-L428","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Stop tracking the local branch and track a remote instead: git branch --set-upstream-to=origin/<branch> <branch>","Or unset the tracking config: git config --unset branch.<branch>.remote and git config --unset branch.<branch>.merge","Push the branch to a remote first (git push -u origin <branch>) then retry"],"exampleFix":"# before\n$ git config branch.my-feature.remote\n.\n# after\n$ git push -u origin my-feature\n$ git config branch.my-feature.remote\norigin","handlingStrategy":"validation","validationCode":"// shell check before invoking hub\nif [ \"$(git config branch.$(git rev-parse --abbrev-ref HEAD).remote)\" = \".\" ]; then\n  echo \"Branch tracks a local branch; set an upstream remote first\" >&2; exit 1\nfi","typeGuard":null,"tryCatchPattern":"// Go caller pattern\nremote, merge, err := branchTrackingInformation(branch)\nif err != nil && strings.Contains(err.Error(), \"tracking another local branch\") {\n    // fall back to explicit remote, e.g. prompt user or default to \"origin\"\n    remote = \"origin\"\n}","preventionTips":["Always create branches with a remote upstream (git push -u origin <branch>)","Avoid branch.<name>.remote=\".\" unless purely local workflows are intended","Check git config branch.<branch>.remote in automation before PR commands"],"tags":["git","branch-tracking","hub-cli"],"backgroundTag":"branch-tracks-local-branch","analyzedSha":"5c547ed804368763064e51f3990851e267e88edd","analyzedAt":"2026-09-01T03:34:15.525Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}