jesseduffield/lazygit · warning
Some of the selected branches are checked out by other workt
Error message
Some of the selected branches are checked out by other worktrees. Select them one by one to delete them.
What it means
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.
Source
Thrown at pkg/gui/controllers/helpers/branches_helper.go:31
"github.com/samber/lo"
)
type BranchesHelper struct {
c *HelperCommon
worktreeHelper *WorktreeHelper
}
func NewBranchesHelper(c *HelperCommon, worktreeHelper *WorktreeHelper) *BranchesHelper {
return &BranchesHelper{
c: c,
worktreeHelper: worktreeHelper,
}
}
func (self *BranchesHelper) ConfirmLocalDelete(branches []*models.Branch) error {
if len(branches) > 1 {
if lo.SomeBy(branches, func(branch *models.Branch) bool { return self.checkedOutByOtherWorktree(branch) }) {
return errors.New(self.c.Tr.SomeBranchesCheckedOutByWorktreeError)
}
} else if self.checkedOutByOtherWorktree(branches[0]) {
return self.promptWorktreeBranchDelete(
branches[0],
self.c.Tr.RemoveWorktreeAndDeleteBranch,
self.c.Tr.DetachWorktreeAndDeleteBranch,
self.deleteLocalBranchesContinuation(branches),
)
}
return self.confirmForceIfUnmerged(branches, func() error {
return self.c.WithWaitingStatus(self.c.Tr.DeletingStatus, func(_ gocui.Task) error {
if err := self.doDeleteLocalBranches(branches); err != nil {
return err
}
self.c.OnUIThread(func() error {
self.c.Contexts().Branches.CollapseRangeSelectionToTop()View on GitHub (pinned to c477a2959b)
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.
Defensive patterns
Strategy: validation
Validate before calling
// before bulk delete, partition branches:
conflicting := lo.Filter(branches, func(b *models.Branch) bool { return checkedOutByOtherWorktree(b) })
if len(conflicting) > 0 && len(branches) > 1 { /* delete the rest individually */ } Prevention
- Prune stale worktrees regularly (Worktrees panel or 'git worktree prune')
- Before bulk-deleting, check 'git worktree list' for HEADs holding selected branches
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- You have already checked out this branch
- Cannot open a pull request for a branch with no upstream
- This branch doesn't exist on remote. You need to push it to
- Cannot fast-forward a branch with no upstream
- Cannot merge branch in detached head state. You might have c
AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15).
Data as JSON: /api/errors/f77c474bc9714b88.
Report an issue: GitHub.