Skip to content
WorktreeWise
Git Worktree Command•Step #7

git worktree prune: Clean Up Stale Git Worktrees

The git worktree prune command cleans up stale administrative records in .git/worktrees/ whose working directories have been manually deleted from disk.

git worktree remove vs git worktree prune

A common point of confusion among developers is the difference between remove and prune:

git worktree remove

Deletes the actual working directory folder from your hard drive AND unregisters its administrative record in .git/worktrees/.

Folder deleted + Metadata cleaned
git worktree prune

Cleans up orphaned administrative metadata when a folder was deleted manually via rm -rf, Finder, or Explorer.

Folder already gone → Cleans metadata only

How Stale Metadata Happens

When you create a worktree, Git registers an entry in .git/worktrees/<name>/. If you later delete that worktree folder using rm -rf, macOS Finder, or Windows Explorer instead of using git worktree remove, Git still thinks the worktree exists.

As a result, you might encounter errors like:

Symptom of Stale Worktree Metadata
fatal: 'feature/auth' is already checked out at '/path/to/old/deleted-folder'

Running git worktree prune immediately scans your filesystem, finds which registered paths no longer exist, and cleans up their obsolete administrative files.

Command Usage & Safe Dry Run

1. Preview changes with dry-run

Always run a dry run first to see what stale records would be pruned:

Terminal
# Preview stale records without deleting anything
$git worktree prune --dry-run --verbose
Dry Run Output
Removing worktrees/project-old-feature: gitdir file points to non-existent location

2. Execute pruning

Terminal
# Prune all stale metadata and display removed entries
$git worktree prune -v

3. Prune by expiration time

You can specify an expiration window so that recently disconnected paths (e.g. from removable drives) are not immediately discarded:

Terminal
# Only prune entries unreachable for longer than 2 weeks
$git worktree prune --expire 2.weeks.ago
WorktreeWise

Prune Stale Worktrees

Try Free

WorktreeWise automatically detects missing or stale worktree folders in real-time, displaying a quick 1-click 'Prune Stale Records' button that keeps your Git repository clean and free of ghost branch checkouts.

Prune orphaned Git worktrees in WorktreeWise

Related commands

If a worktree folder was moved instead of deleted, do not prune it! Instead, restore the connection using git worktree repair.