Skip to content
WorktreeWise
#git#troubleshooting#git-internals#recovery

Worktree metadata corrupted

W

WorktreeWise Engineering Team

Updated Sep 2026•6 min read
⚡

TL;DR: The 30-Second Summary

Corrupted worktree metadata occurs when files inside `.git/worktrees/` are modified, partially restored from conflicting backups, or damaged by disk errors. Inspect individual metadata folders, fix `gitdir` and `commondir` pointers, or run `git worktree repair`.

The Real-Life Scenario

“After an incomplete Dropbox sync or partial backup restore, `.git/worktrees/` contains duplicate directories and corrupted HEAD files. Running any `git worktree` command outputs `fatal: corrupted worktree administrative files`.”

Git stores the administrative state of each linked worktree inside `.git/worktrees/<name>/`. This folder contains lightweight text files that Git reads during every operation. Understanding how these files interact enables you to repair even severe corruption in minutes.

The Structure of `.git/worktrees/<name>/`

Inside each worktree record, Git maintains five critical files: `gitdir` (pointer to the worktree's `.git`), `commondir` (pointer to main `.git`), `HEAD` (active ref), `index` (staged cache), and optional `locked`.

What you see in the terminal:

terminal output
$ git worktree list
fatal: could not read '/projects/main/.git/worktrees/feat-api/gitdir': No such file or directory
🔍

Under the Hood: Git Plumbing & Architecture

If `gitdir` or `commondir` is missing or corrupted, Git cannot map the worktree to the main object database. Running `git worktree repair` scans all registered paths and recreates missing pointer files.

Quick Command Recipes

Copy and adapt these commands directly in your terminal:

Repair all worktree registrations

Audits and rebuilds corrupted pointer metadata across all worktrees.

bash
git worktree repair

Inspect metadata folder structure

Lists all registered worktree administrative folders in the main repository.

bash
ls -la .git/worktrees/
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

Inspect `.git/worktrees/` in your main repository

Check which subfolder is corrupted.

terminal
ls -la .git/worktrees/
Expected Output:
drwxr-xr-x feat-api/
drwxr-xr-x feat-ui/
2

Check the contents of the corrupted folder

Verify that `commondir` and `gitdir` exist.

terminal
cat .git/worktrees/feat-api/commondir
Expected Output:
../..
3

Run automated repair

Allow Git to regenerate corrupt pointers.

terminal
git worktree repair /projects/feat-api
Expected Output:
repair worktree: /projects/feat-api
4

Remove unrecoverable ghost folders

If an entry in `.git/worktrees/` has no matching folder on disk and repair cannot resolve it, delete that specific subfolder from `.git/worktrees/`.

terminal
rm -rf .git/worktrees/broken-ghost-entry

Edge Cases & Advanced Scenarios

Dropbox or cloud drive sync conflicts

Cloud sync tools create `gitdir (Conflicted Copy)` files inside `.git`. Delete conflicted duplicate files and exclude `.git/` from sync.

⚠️

Common Mistakes to Avoid

❌ Mistake: Deleting the entire `.git/worktrees/` folder

Why it causes trouble: Disassociates all active worktrees simultaneously.

What to do instead: Inspect and repair individual subfolders instead of deleting the whole directory.

✓

Verification Checklist

  • ✓`git worktree list --porcelain` executes with exit code 0
  • ✓All active worktrees appear in the list without fatal errors
💡

Senior Engineering Tips

  • ★Never store Git repositories inside cloud-synced folders (Dropbox, Google Drive, OneDrive) without excluding `.git` to prevent file lock contention.

Key Takeaways

  • 01.Worktree administrative metadata lives in `.git/worktrees/<name>/`.
  • 02.`git worktree repair` automates rebuilding damaged pointers.
  • 03.Cloud sync tools are the #1 cause of corrupted metadata.
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 interface diagnosing and repairing worktree metadata
WorktreeWise interface diagnosing and repairing worktree metadata
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 →