Fix cannot delete branch checked out at errors

maintenance & cleanup

// what it does

git branch -d refuses to delete a branch that any worktree has checked out — even one whose directory you deleted ages ago. The order is always: remove (or prune) the worktree first, then delete the branch. -d only deletes merged branches; -D forces.

// shell

$ git worktree remove ../myapp-agents/auth
$ git worktree prune
$ git branch -d agent/auth

// gotcha

If the blocking path no longer exists on disk, the registration is stale — git worktree prune clears it and the branch delete then succeeds. Check git worktree list first; the error message includes the exact path holding the branch.

// resources