jesseduffield/lazygit · info

You have already checked out this branch

Error message

You have already checked out this branch

What it means

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.

Source

Thrown at pkg/gui/controllers/branches_controller.go:409

	}

	return self.c.Menu(types.CreateMenuOptions{
		Title: self.c.Tr.BranchUpstreamOptionsTitle,
		Items: options,
	})
}

func (self *BranchesController) Context() types.Context {
	return self.context()
}

func (self *BranchesController) context() *context.BranchesContext {
	return self.c.Contexts().Branches
}

func (self *BranchesController) press(selectedBranch *models.Branch) error {
	if selectedBranch == self.c.Helpers().Refs.GetCheckedOutRef() {
		return errors.New(self.c.Tr.AlreadyCheckedOutBranch)
	}

	worktreeForRef, ok := self.worktreeForBranch(selectedBranch)
	if ok && !worktreeForRef.IsCurrent {
		return self.promptToCheckoutWorktree(worktreeForRef)
	}

	self.c.LogAction(self.c.Tr.Actions.CheckoutBranch)
	return self.c.Helpers().Refs.CheckoutRef(selectedBranch.Name, types.CheckoutRefOptions{})
}

func (self *BranchesController) notPulling() *types.DisabledReason {
	currentBranch := self.c.Helpers().Refs.GetCheckedOutRef()
	if currentBranch != nil {
		op := self.c.State().GetItemOperation(currentBranch)
		if op == types.ItemOperationFastForwarding || op == types.ItemOperationPulling {
			return &types.DisabledReason{Text: self.c.Tr.CantCheckoutBranchWhilePulling}
		}

View on GitHub (pinned to c477a2959b)

Solutions

  1. Select a different branch before pressing checkout
  2. If you meant to discard changes / reset, use the rebase/reset menu on the branch instead of checkout
  3. Refresh the view (press 'r') if the checked-out marker looks stale after worktree operations
Defensive patterns

Strategy: validation

Validate before calling

// UI-level guard: disable checkout for the checked-out branch
func canCheckout(selected, checkedOut *models.Branch) bool {
    return selected.Name != checkedOut.Name
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15). Data as JSON: /api/errors/561028aa0c850182. Report an issue: GitHub.