{"record":{"id":"f77c474bc9714b88","repo":"jesseduffield/lazygit","slug":"some-of-the-selected-branches-are-checked-out-by-o","errorCode":null,"errorMessage":"Some of the selected branches are checked out by other worktrees. Select them one by one to delete them.","messagePattern":"Some of the selected branches are checked out by other worktrees\\. Select them one by one to delete them\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/gui/controllers/helpers/branches_helper.go","lineNumber":31,"sourceCode":"\t\"github.com/samber/lo\"\n)\n\ntype BranchesHelper struct {\n\tc              *HelperCommon\n\tworktreeHelper *WorktreeHelper\n}\n\nfunc NewBranchesHelper(c *HelperCommon, worktreeHelper *WorktreeHelper) *BranchesHelper {\n\treturn &BranchesHelper{\n\t\tc:              c,\n\t\tworktreeHelper: worktreeHelper,\n\t}\n}\n\nfunc (self *BranchesHelper) ConfirmLocalDelete(branches []*models.Branch) error {\n\tif len(branches) > 1 {\n\t\tif lo.SomeBy(branches, func(branch *models.Branch) bool { return self.checkedOutByOtherWorktree(branch) }) {\n\t\t\treturn errors.New(self.c.Tr.SomeBranchesCheckedOutByWorktreeError)\n\t\t}\n\t} else if self.checkedOutByOtherWorktree(branches[0]) {\n\t\treturn self.promptWorktreeBranchDelete(\n\t\t\tbranches[0],\n\t\t\tself.c.Tr.RemoveWorktreeAndDeleteBranch,\n\t\t\tself.c.Tr.DetachWorktreeAndDeleteBranch,\n\t\t\tself.deleteLocalBranchesContinuation(branches),\n\t\t)\n\t}\n\n\treturn self.confirmForceIfUnmerged(branches, func() error {\n\t\treturn self.c.WithWaitingStatus(self.c.Tr.DeletingStatus, func(_ gocui.Task) error {\n\t\t\tif err := self.doDeleteLocalBranches(branches); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tself.c.OnUIThread(func() error {\n\t\t\t\tself.c.Contexts().Branches.CollapseRangeSelectionToTop()","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/gui/controllers/helpers/branches_helper.go#L13-L49","documentation":"Returned by BranchesHelper.ConfirmLocalDelete when deleting multiple selected branches and at least one is checked out in another linked worktree. For bulk deletion lazygit refuses to interactively resolve per-branch worktree conflicts, so it aborts the whole operation and asks the user to delete the affected branches individually, where the single-branch path can offer remove/detach-worktree choices.","triggerScenarios":"Range- or multi-selecting branches in the Branches panel (e.g. shift-down) and pressing delete (local) while any selected branch is the HEAD of another 'git worktree'. checkedOutByOtherWorktree compares the branch against worktrees known to the model.","commonSituations":"Teams using git worktrees for parallel hotfix/review branches; CI-style checkout directories sharing one repo; long-lived 'scratch' worktrees holding old feature branches that pile up in the branch list.","solutions":["Delete the worktree-checked-out branches one at a time; lazygit then offers to remove or detach the worktree first.","Or remove the worktree outright (Worktrees panel) before bulk-deleting branches.","Or detach that worktree's HEAD (checkout a different branch there) so the branch is no longer checked out anywhere else.","Then re-run the multi-branch delete on the remaining branches."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before bulk delete, partition branches:\nconflicting := lo.Filter(branches, func(b *models.Branch) bool { return checkedOutByOtherWorktree(b) })\nif len(conflicting) > 0 && len(branches) > 1 { /* delete the rest individually */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prune stale worktrees regularly (Worktrees panel or 'git worktree prune')","Before bulk-deleting, check 'git worktree list' for HEADs holding selected branches"],"tags":["git","worktrees","branches","bulk-delete","guard"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}