{"record":{"id":"561028aa0c850182","repo":"jesseduffield/lazygit","slug":"you-have-already-checked-out-this-branch","errorCode":null,"errorMessage":"You have already checked out this branch","messagePattern":"You have already checked out this branch","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"pkg/gui/controllers/branches_controller.go","lineNumber":409,"sourceCode":"\t}\n\n\treturn self.c.Menu(types.CreateMenuOptions{\n\t\tTitle: self.c.Tr.BranchUpstreamOptionsTitle,\n\t\tItems: options,\n\t})\n}\n\nfunc (self *BranchesController) Context() types.Context {\n\treturn self.context()\n}\n\nfunc (self *BranchesController) context() *context.BranchesContext {\n\treturn self.c.Contexts().Branches\n}\n\nfunc (self *BranchesController) press(selectedBranch *models.Branch) error {\n\tif selectedBranch == self.c.Helpers().Refs.GetCheckedOutRef() {\n\t\treturn errors.New(self.c.Tr.AlreadyCheckedOutBranch)\n\t}\n\n\tworktreeForRef, ok := self.worktreeForBranch(selectedBranch)\n\tif ok && !worktreeForRef.IsCurrent {\n\t\treturn self.promptToCheckoutWorktree(worktreeForRef)\n\t}\n\n\tself.c.LogAction(self.c.Tr.Actions.CheckoutBranch)\n\treturn self.c.Helpers().Refs.CheckoutRef(selectedBranch.Name, types.CheckoutRefOptions{})\n}\n\nfunc (self *BranchesController) notPulling() *types.DisabledReason {\n\tcurrentBranch := self.c.Helpers().Refs.GetCheckedOutRef()\n\tif currentBranch != nil {\n\t\top := self.c.State().GetItemOperation(currentBranch)\n\t\tif op == types.ItemOperationFastForwarding || op == types.ItemOperationPulling {\n\t\t\treturn &types.DisabledReason{Text: self.c.Tr.CantCheckoutBranchWhilePulling}\n\t\t}","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/gui/controllers/branches_controller.go#L391-L427","documentation":"Returned by BranchesController.press (branches_controller.go:409) via the AlreadyCheckedOutRef comparison: pressing enter on the branch that is the currently checked out ref is a no-op, and lazygit reports it rather than running a pointless checkout. The message is the translated Tr.AlreadyCheckedOutBranch string.","triggerScenarios":"In the local branches panel, pressing the checkout key on the branch marked with a '*' (HEAD). The controller compares selectedBranch to Helpers().Refs.GetCheckedOutRef() and short-circuits.","commonSituations":"Muscle-memory pressing enter on the top branch (usually the checked-out one); stale view after switching branches elsewhere (e.g. in a linked worktree) so the marked branch is outdated.","solutions":["Select a different branch before pressing checkout","If you meant to discard changes / reset, use the rebase/reset menu on the branch instead of checkout","Refresh the view (press 'r') if the checked-out marker looks stale after worktree operations"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// UI-level guard: disable checkout for the checked-out branch\nfunc canCheckout(selected, checkedOut *models.Branch) bool {\n    return selected.Name != checkedOut.Name\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Look for the '*' marker / checked-out highlight before pressing checkout","Refresh the branches view after worktree or external git operations","Treat this message as informational, not a failure"],"tags":["git","branches","ui","checkout"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}