git data_error ai_generated true

致命:损坏的树对象:<哈希>:'<文件名>' 的重复条目

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

ID: git/merge-tree-corrupted

其他格式: JSON · Markdown 中文 · English
75%修复率
83%置信度
1证据数
2023-09-05首次发现

版本兼容性

版本状态引入弃用备注
git 2.37.0 active
git 2.38.2 active
git 2.39.1 active

根因分析

Git 对象数据库中的树对象包含同一文件路径的重复条目,表明由于硬件故障、手动操作对象或有漏洞的工具导致仓库损坏。

English

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

官方文档

https://git-scm.com/docs/git-fsck

解决方案

  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
  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>'

无效尝试

常见但无效的做法:

  1. 40% 失败

    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.

  2. 65% 失败

    git gc may fail or skip corrupt objects without fixing the duplicate entry, and can make the corruption harder to recover by packing objects.