git
data_error
ai_generated
true
fatal: corrupt tree: <hash>: duplicate entries for '<filename>'
ID: git/merge-tree-corrupted
75%Fix Rate
83%Confidence
1Evidence
2023-09-05First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| git 2.37.0 | active | — | — | — |
| git 2.38.2 | active | — | — | — |
| git 2.39.1 | active | — | — | — |
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.
generic中文
Git 对象数据库中的树对象包含同一文件路径的重复条目,表明由于硬件故障、手动操作对象或有漏洞的工具导致仓库损坏。
Official Documentation
https://git-scm.com/docs/git-fsckWorkarounds
-
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
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
-
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>'
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>'
中文步骤
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
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
Common approaches that don't work:
-
40% fail
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.
-
65% 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.