Skip to content
WorktreeWise
#git#troubleshooting#repair#git-fsck

Repair a broken worktree

W

WorktreeWise Engineering Team

Updated Sep 2026•6 min read
⚡

TL;DR: The 30-Second Summary

A broken worktree occurs when index files are corrupted, gitdir pointers are severed, or commits were interrupted during a crash. Diagnose with `git fsck`, repair pointers with `git worktree repair`, and reset the worktree index safely.

The Real-Life Scenario

“A workstation crashes during a forced system reboot while a build was running in a secondary worktree. Upon rebooting, opening the worktree yields `error: bad signature 0x00000000` and `fatal: index file corrupt`.”

Corrupted worktrees can appear terrifying because terminal commands stop responding. However, because worktrees share the underlying object database with the main repository, your commit history and blobs are almost always safe.

Anatomy of Worktree Corruption

Worktrees maintain their own private `index`, `HEAD`, and `ORIG_HEAD` files in `.git/worktrees/<name>/`. If power loss occurs while Git is writing to the index, the index file is truncated with null bytes.

What you see in the terminal:

terminal output
$ git status
fatal: index file corrupt

$ git worktree list
fatal: could not read worktree /projects/feature: Not a directory
🔍

Under the Hood: Git Plumbing & Architecture

The worktree's index file stores staged file state and inode cache metadata. Since the index is just a staging cache, deleting a corrupted index file and checking it out again from `HEAD` restores 100% of tracked repository state without data loss.

Quick Command Recipes

Copy and adapt these commands directly in your terminal:

Repair worktree pointers

Fixes severed bidirectional links between all worktrees and the main repository.

bash
git worktree repair

Rebuild a corrupted worktree index

Deletes the corrupt index file and rebuilds it cleanly from the worktree's HEAD commit.

bash
rm .git/worktrees/<name>/index
git -C /path/to/worktree reset

Verify repository integrity

Performs full consistency check on all Git objects and refs.

bash
git fsck --no-dangling
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

Identify which part is broken

Determine whether the issue is a pointer failure or a corrupted index file.

terminal
git -C /projects/broken-wt rev-parse --git-dir
Expected Output:
/projects/main/.git/worktrees/broken-wt
Tip:If this command fails, the pointer is broken. If it succeeds, the index or working tree is corrupted.
2

Repair pointers first

Run `git worktree repair` from the main repository.

terminal
git worktree repair /projects/broken-wt
Expected Output:
repair worktree: /projects/broken-wt
3

Recover from index corruption if needed

If Git reports index file corrupt, delete the worktree's private index file and reset.

terminal
rm /projects/main/.git/worktrees/broken-wt/index
4

Rebuild index from current HEAD

Run `git reset` inside the worktree directory to regenerate a clean index.

terminal
git -C /projects/broken-wt reset
Expected Output:
Unstaged changes after reset:
M	src/index.ts
5

Verify repository health

Run `git status` inside the repaired worktree.

terminal
git -C /projects/broken-wt status
Expected Output:
On branch feature-work
nothing to commit, working tree clean

Edge Cases & Advanced Scenarios

Worktree is locked and preventing operations

If a lock file `.git/worktrees/<name>/locked` was left behind after a crash, unlock it with `git worktree unlock`.

bash
git worktree unlock /projects/broken-wt
⚠️

Common Mistakes to Avoid

❌ Mistake: Deleting the main `.git` folder in panic

Why it causes trouble: Destroys all branches, tags, and commits for the entire project.

What to do instead: Only modify files inside `.git/worktrees/<name>/` for that specific worktree.

✓

Verification Checklist

  • ✓`git fsck --no-dangling` reports clean repository state
  • ✓`git -C <path> status` returns zero errors
💡

Senior Engineering Tips

  • ★Because worktrees share the main object database, you can always recreate a broken worktree from scratch in seconds without losing commits.

Key Takeaways

  • 01.The worktree index is a rebuildable cache: deleting a corrupted index does not lose committed code.
  • 02.`git worktree repair` fixes severed pointers.
  • 03.The shared object database keeps your history safe even when individual worktrees crash.
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 Repair Worktree feature diagnosing and fixing broken worktree states
WorktreeWise Repair Worktree feature diagnosing and fixing broken worktree states
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 →