# fatal: corrupt tree: <hash>: duplicate entries for '<filename>'

- **ID:** `git/merge-tree-corrupted`
- **Domain:** git
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 75%

## Root Cause

A tree object in the Git object database contains duplicate entries for the same file path, indicating repository corruption due to hardware failure, manual object manipulation, or buggy tools.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| git 2.37.0 | active | — | — |
| git 2.38.2 | active | — | — |
| git 2.39.1 | active | — | — |

## Workarounds

1. **Run 'git fsck --full' to identify all corrupt objects, then use 'git replace --edit <hash>' to manually remove the duplicate entry from the tree object** (70% success)
   ```
   Run 'git fsck --full' to identify all corrupt objects, then use 'git replace --edit <hash>' to manually remove the duplicate entry from the tree object
   ```
2. **If a remote backup exists, reclone the repository and cherry-pick local commits: 'git clone <remote> new-repo && cd new-repo && git remote add old ../old-repo && git fetch old && git cherry-pick <local-commits>'** (80% success)
   ```
   If a remote backup exists, reclone the repository and cherry-pick local commits: 'git clone <remote> new-repo && cd new-repo && git remote add old ../old-repo && git fetch old && git cherry-pick <local-commits>'
   ```

## Dead Ends

- **** — Deleting all objects is extreme and may lose local branches, stashes, or uncommitted work; a reclone should only be done if remote is healthy, but it ignores local-only objects. (40% fail)
- **** — git gc may fail or skip corrupt objects without fixing the duplicate entry, and can make the corruption harder to recover by packing objects. (65% fail)
