Interview Prep/Git & GitHub/Lost Work, HEAD and History Problems

`error: Cannot delete branch 'feature/x' checked out at '/home/dev/app-wt'`

IntermediateTroubleshootingLost Work, HEAD and History Problems
Answer

Likely causes → The branch is the current branch in another worktree.

Diagnose → git worktree list.

Fix → Remove or switch that worktree first (git worktree remove ../app-wt), then git branch -d feature/x. If the directory was deleted manually, run git worktree prune.

Prevent → Remove worktrees with git worktree remove, not rm -rf.

All Git & GitHub questions Roadmap: Git & GitHub

More on Lost Work, HEAD and History Problems