Remove a worktree safely
maintenance & cleanup
// what it does
git worktree remove deletes the working directory and unregisters it from .git/worktrees — the clean, complete way to retire a worktree. It only proceeds when the tree is clean (no untracked files, no modified tracked files); --force overrides for unclean trees, and --force twice for locked ones.
// shell
$ git worktree remove ../myapp-hotfix$ git worktree remove --force ../myapp-hotfix// gotcha
Removing a worktree never deletes its branch or commits — the branch simply stops being checked out anywhere. The main worktree can't be removed at all.