Git Worktree Prune or Remove: Delete a Worktree Cleanly
Use git worktree remove to delete a worktree you still have. Use git worktree prune to clean up after a worktree folder you already deleted.
The Fix
Delete a worktree and its directory, then its branch if you no longer need it:
git worktree remove ../repo-feature
git branch -d feature
If you already ran rm -rf on the folder, Git still lists it as prunable:
/src/repo 54d33c8 [main]
/src/quick-fix 54d33c8 [quick-fix] prunable
Preview the cleanup, then run it:
git worktree prune --dry-run -v
git worktree prune -v
Removing worktrees/quick-fix: gitdir file points to non-existent location
Remove vs Prune
git worktree remove <path> | git worktree prune | |
|---|---|---|
| Use when | The worktree directory still exists | The directory is already gone |
| Deletes the directory | Yes | No, there is nothing left to delete |
Deletes the record in .git/worktrees/ | Yes | Yes, for every missing worktree |
| Deletes the branch | No | No |
| Skips locked worktrees | Yes, unless you pass -f twice | Yes |
Neither command deletes the branch. After a prune, git branch --list quick-fix still shows quick-fix. Delete it with git branch -d, or -D if it has unmerged commits.
git gc also prunes stale worktree records once they are older than gc.worktreePruneExpire, which defaults to three months. Run git worktree prune when you want the entry gone now.
Why It Fails
remove refuses a worktree with uncommitted work:
fatal: '../repo-feature' contains modified or untracked files, use --force to delete it
Commit or copy what you need, then add --force. A locked worktree needs git worktree unlock first, or -f -f. Remove a locked Git worktree covers that case. remove also refuses the main worktree with fatal: '.' is a main working tree.
If you moved a worktree folder instead of deleting it, Git marks the old path prunable too. Do not prune it. Run git worktree repair <new-path> to reconnect it.
How Treq Handles It
Deleting a workspace in Treq drops the workspace, its directory and its local metadata in one step. There is no stale entry to prune afterward. See Managing Workspaces.