How to remove old git worktrees
git worktree remove ../repo-my-taskGit refuses if the worktree has uncommitted or untracked files, so a clean one is safe to remove. Its branch stays until you delete it.
1. List your worktrees
Run it in the main repository. AI coding agents often get one worktree per task, each with its own node_modules and build output, so they add up fast.
git worktree list
2. Check for work you haven’t saved
The first command shows uncommitted changes. The second shows commits on the branch that aren’t on any remote yet.
git -C ../repo-my-task status --short git log --oneline my-task --not --remotes
3. Remove it, then its branch
git branch -d only deletes a branch that’s already merged.
git worktree remove ../repo-my-task git branch -d my-task
4. Clean up worktrees deleted by hand
If you deleted a worktree folder in Finder, git still lists it. This clears those stale entries.
git worktree prune
Is it safe?
Both checks protect you: git won’t remove a worktree with uncommitted changes or delete an unmerged branch. --force skips them, so use it only when you’re sure. Squash-merged branches look unmerged to git, so check the pull request before forcing.