Skip to content
WorktreeWise
#git#troubleshooting#prune#worktree

Missing worktree directory

W

WorktreeWise Engineering Team

Updated Sep 2026•5 min read
⚡

TL;DR: The 30-Second Summary

When a worktree directory is deleted outside Git (via File Explorer, Finder, or `rm -rf`), Git continues to track it as an active checkout. This prevents other checkouts of its branch. Clean up the zombie record using `git worktree prune --dry-run` followed by `git worktree prune`.

The Real-Life Scenario

“A teammate deletes a temporary worktree folder using macOS Finder. Later, when trying to delete the merged feature branch, Git refuses because it still considers the branch actively checked out in the deleted path.”

Git does not continuously monitor your filesystem in the background. If a folder is deleted through your desktop environment or terminal without telling Git, the administrative records inside `.git/worktrees/` remain active. Git considers the worktree alive—just missing from disk.

Ghost Worktrees and Branch Locks

When you run `git worktree list`, missing folders appear marked as `prunable` or missing. Even though the files are gone, the branch attached to that worktree cannot be deleted, checked out elsewhere, or re-created until Git prunes its record.

What you see in the terminal:

terminal output
$ git worktree list
/repos/main           04e3a1f [main]
/repos/feature-login  18c42bb [feature-login] (prunable)

$ git branch -d feature-login
error: Cannot delete branch 'feature-login' checked out at '/repos/feature-login'
🔍

Under the Hood: Git Plumbing & Architecture

Git stores the registered worktree in `.git/worktrees/<name>/`. Because the branch reference in `.git/refs/heads/` is still bound to the worktree's `HEAD`, any command that modifies the branch fails with a safety lock until the administrative folder is pruned.

Quick Command Recipes

Copy and adapt these commands directly in your terminal:

Check for missing and prunable worktrees

Shows all registered worktrees and flags missing ones with (prunable).

bash
git worktree list -v

Preview what will be pruned

Lists the exact metadata folders that will be deleted without touching real data.

bash
git worktree prune --dry-run --verbose

Clean up missing worktrees

Safely removes administrative records for directories that no longer exist on disk.

bash
git worktree prune -v
TUTORIAL

Step-by-Step Practical Walkthrough

Follow these verified steps to safely resolve the issue and guarantee that your filesystem and Git references are in sync.

1

List worktrees to find missing entries

Run the verbose list command to identify which directory was deleted.

terminal
git worktree list -v
Expected Output:
/repos/main           04e3a1f [main]
/repos/feature-login  18c42bb [feature-login] prunable (gitdir points to non-existent location)
2

Dry run the prune command

Always verify what Git plans to prune to avoid accidentally retiring locked or temporarily unmounted drives.

terminal
git worktree prune --dry-run -v
Expected Output:
Removing worktrees/feature-login: gitdir points to non-existent location
3

Execute the prune operation

Run `git worktree prune` to purge the orphaned administrative metadata.

terminal
git worktree prune -v
Expected Output:
Removing worktrees/feature-login
4

Verify the branch is now unlocked

Confirm that the branch can now be safely checked out or deleted.

terminal
git branch -d feature-login
Expected Output:
Deleted branch feature-login (was 18c42bb).

Edge Cases & Advanced Scenarios

Worktree directory is on an unmounted external drive

If your worktree resides on a flash drive or external SSD that is unplugged, pruning will permanently retire its registration. Lock external worktrees before disconnecting them!

bash
git worktree lock --reason 'external drive' /media/ssd/worktree
⚠️

Common Mistakes to Avoid

❌ Mistake: Manually deleting folders inside `.git/worktrees/`

Why it causes trouble: Risk deleting active metadata, causing corrupted repository states.

What to do instead: Always let `git worktree prune` handle cleanup.

✓

Verification Checklist

  • ✓`git worktree list` displays only existing filesystem paths
  • ✓The associated branch is released and can be deleted or checked out elsewhere
💡

Senior Engineering Tips

  • ★WorktreeWise periodically audits worktree paths and highlights missing directories with an intuitive prune action right in the sidebar.

Key Takeaways

  • 01.Deleting a worktree folder manually leaves behind an active Git registration.
  • 02.`git worktree prune` synchronizes Git's metadata with reality.
  • 03.Lock worktrees on removable drives to prevent accidental pruning.
TOOL

How WorktreeWise Solves This Visually

WorktreeWise eliminates the manual friction and mental overhead of CLI flags. It displays real-time branch states, uncommitted modifications, active terminals, and lock statuses across all worktrees on a single visual dashboard.

WorktreeWise Prune Worktrees interface showing prunable entries
WorktreeWise Prune Worktrees interface showing prunable entries
W

WorktreeWise Engineering Publication

Written and curated by the core WorktreeWise team. We build developer tools that turn Git worktrees, workflows, and parallel AI coding agents into second nature.

Related Troubleshooting Guides

View all troubleshooting →