Git fsck --unreachable --lost-found 不会将对象作为文件保存在 lost-found 目录中

Git fsck --unreachable --lost-found does not save objects as files at the lost-found directory

我使用 fsck 发现我有一些悬空对象,而且(在数量上)更多的是无法到达的对象。

fsck --lost-found 确实将悬空对象保存为 lost-found 目录中的文件,但是当我想让它用 fsck --unreachable --lost-found 写入所有无法访问的对象时,它不会写入它们,所以我最终错过了一些无法到达的对象。

为什么会发生这种情况,有没有办法让 Git 将那些无法访问的对象也写入文件?

找到解决方案: --lost-found 仅支持悬挂对象,根据 Git 文档:

--lost-found Write dangling objects into .git/lost-found/commit/ or .git/lost-found/other/, depending on type. If the object is a blob, the contents are written into the file, rather than its object name.

https://git-scm.com/docs/git-fsck#Documentation/git-fsck.txt---lost-found