{"record":{"id":"783923c35a90e82e","repo":"mislav/hub","slug":"could-not-determine-project-for-head-branch","errorCode":null,"errorMessage":"could not determine project for head branch","messagePattern":"could not determine project for head branch","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/pull_request.go","lineNumber":151,"sourceCode":"\nfunc pullRequest(cmd *Command, args *Args) {\n\tlocalRepo, err := github.LocalRepo()\n\tutils.Check(err)\n\n\tcurrentBranch, currentBranchErr := localRepo.CurrentBranch()\n\n\tbaseProject, err := localRepo.MainProject()\n\tutils.Check(err)\n\n\thost, err := github.CurrentConfig().PromptForHost(baseProject.Host)\n\tif err != nil {\n\t\tutils.Check(github.FormatError(\"creating pull request\", err))\n\t}\n\tclient := github.NewClientWithHost(host)\n\n\ttrackedBranch, headProject, _ := localRepo.RemoteBranchAndProject(host.User, false)\n\tif headProject == nil {\n\t\tutils.Check(fmt.Errorf(\"could not determine project for head branch\"))\n\t}\n\n\tvar (\n\t\tbase, head string\n\t)\n\n\tif flagPullRequestBase := args.Flag.Value(\"--base\"); flagPullRequestBase != \"\" {\n\t\tbaseProject, base = parsePullRequestProject(baseProject, flagPullRequestBase)\n\t}\n\n\tif flagPullRequestHead := args.Flag.Value(\"--head\"); flagPullRequestHead != \"\" {\n\t\theadProject, head = parsePullRequestProject(headProject, flagPullRequestHead)\n\t}\n\n\tbaseRemote, _ := localRepo.RemoteForProject(baseProject)\n\tif base == \"\" && baseRemote != nil {\n\t\tbase = localRepo.DefaultBranch(baseRemote).ShortName()\n\t}","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/mislav/hub/blob/5c547ed804368763064e51f3990851e267e88edd/commands/pull_request.go#L133-L169","documentation":"pullRequest determines the head project (owner/repo) for the new pull request via localRepo.RemoteBranchAndProject. If the current branch has no resolvable remote project on the given host, the command cannot determine where the head branch lives and aborts with this error via utils.Check.","triggerScenarios":"Creating a pull request when the current branch (or repo) has no remote pointing to the GitHub host, or the branch is not pushed and no project can be deduced for host.User.","commonSituations":"Fresh local repo without a GitHub remote; fork workflows where remote names differ (not origin); enterprise host mismatch where the remote URL doesn't match the configured host; branch never pushed.","solutions":["Add a remote pointing at the GitHub repo: git remote add origin git@github.com:owner/repo.git","Push the current branch: git push -u origin <branch>","Ensure the remote URL matches the configured GitHub host (or pass --host / GITHUB_HOST appropriately)","Specify the head explicitly with -h <owner>:<branch> if supported"],"exampleFix":"# before\n$ git remote -v\n(no output)\n# after\n$ git remote add origin git@github.com:me/myrepo.git\n$ git push -u origin my-feature\n$ hub pull-request","handlingStrategy":"validation","validationCode":"git remote get-url origin >/dev/null 2>&1 || { echo \"Add origin remote first\"; exit 1; }\ngit ls-remote --heads origin $(git rev-parse --abbrev-ref HEAD) | grep -q . || { echo \"Push branch first\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure a remote URL matching the GitHub host exists before PR commands","Push branches with -u before opening PRs","For forks, pass -h <owner>:<branch> explicitly","Verify GITHUB_HOST matches your remote host for enterprise"],"tags":["git","remote","pull-request","hub-cli"],"backgroundTag":"no-remote-for-branch","analyzedSha":"5c547ed804368763064e51f3990851e267e88edd","analyzedAt":"2026-09-01T03:34:15.525Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}