{"record":{"id":"e64b196703eaf61c","repo":"jesseduffield/lazygit","slug":"cannot-open-a-pull-request-for-a-branch-with-no-up","errorCode":null,"errorMessage":"Cannot open a pull request for a branch with no upstream","messagePattern":"Cannot open a pull request for a branch with no upstream","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/gui/controllers/branches_controller.go","lineNumber":453,"sourceCode":"}\n\nfunc (self *BranchesController) promptToCheckoutWorktree(worktree *models.Worktree) error {\n\tprompt := utils.ResolvePlaceholderString(self.c.Tr.AlreadyCheckedOutByWorktree, map[string]string{\n\t\t\"worktreeName\": worktree.Name,\n\t})\n\n\treturn self.c.ConfirmIf(!self.c.UserConfig().Gui.SkipSwitchWorktreeOnCheckoutWarning, types.ConfirmOpts{\n\t\tTitle:  self.c.Tr.SwitchToWorktree,\n\t\tPrompt: prompt,\n\t\tHandleConfirm: func() error {\n\t\t\treturn self.c.Helpers().Worktree.Switch(worktree, context.LOCAL_BRANCHES_CONTEXT_KEY)\n\t\t},\n\t})\n}\n\nfunc (self *BranchesController) handleCreatePullRequest(selectedBranch *models.Branch) error {\n\tif !selectedBranch.IsTrackingRemote() {\n\t\treturn errors.New(self.c.Tr.PullRequestNoUpstream)\n\t}\n\treturn self.createPullRequest(selectedBranch.UpstreamBranch, \"\")\n}\n\nfunc (self *BranchesController) handleCreatePullRequestMenu(selectedBranch *models.Branch) error {\n\tcheckedOutBranch := self.c.Helpers().Refs.GetCheckedOutRef()\n\n\treturn self.createPullRequestMenu(selectedBranch, checkedOutBranch)\n}\n\nfunc (self *BranchesController) getPullRequestURL() (string, error) {\n\tbranch := self.context().GetSelected()\n\tif pr, ok := self.c.Model().PullRequestsMap[branch.Name]; ok {\n\t\treturn pr.Url, nil\n\t}\n\n\tbranchExistsOnRemote := self.c.Git().Remote.CheckRemoteBranchExists(branch.Name)\n","sourceCodeStart":435,"sourceCodeEnd":471,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/gui/controllers/branches_controller.go#L435-L471","documentation":"Returned by BranchesController.handleCreatePullRequest (branches_controller.go:453) via Tr.PullRequestNoUpstream. Creating a PR requires a remote branch to target; if the selected branch's IsTrackingRemote() is false (no upstream configured), lazygit cannot build the PR URL and reports this.","triggerScenarios":"Pressing 'o'/'O' (create PR) on a locally created branch that was never pushed with -u, or whose upstream tracking was removed. IsTrackingRemote checks that Pushble/Trackable remote-tracking state exists.","commonSituations":"New feature branches created in lazygit but not yet pushed; branches after deleting the remote-tracking ref; working offline after cloning with --single-branch so other branches lack upstream config.","solutions":["Push with upstream first: 'git push -u origin <branch>' (lazygit's push does this when the branch has no upstream)","Or set upstream manually: 'git branch --set-upstream-to=origin/<branch>' if the remote branch already exists","Then retry create pull request from the branches panel"],"exampleFix":"# shell fix\ngit push -u origin $(git branch --show-current)\n# then retry 'o' on the branch in lazygit","handlingStrategy":"validation","validationCode":"func branchReadyForPR(b *models.Branch) bool {\n    return b.IsTrackingRemote()\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Push new branches with -u as a habit (lazygit prompts for this on first push)","Check the upstream column in the branches panel before creating PRs","After remote ref cleanup, re-establish tracking before PR actions"],"tags":["git","pull-request","upstream","branches"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}