ENOENT
git
data_error
ai_generated
partial
error: failed to read object <hash> from the object database: No such file or directory
ID: git/error-failed-to-read-object-from-odb
70%Fix Rate
85%Confidence
1Evidence
2023-11-08First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| git 2.28.0 | active | — | — | — |
| git 2.35.0 | active | — | — | — |
| git 2.45.0 | active | — | — | — |
Root Cause
A required Git object (commit, tree, or blob) is missing from the .git/objects directory, often due to repository corruption, incomplete clone, or a failed garbage collection.
generic中文
所需的 Git 对象(提交、树或 blob)在 .git/objects 目录中缺失,通常是由于仓库损坏、克隆不完整或垃圾回收失败。
Official Documentation
https://git-scm.com/docs/git-fsckWorkarounds
-
70% success git fetch origin refs/heads/*:refs/remotes/origin/* # Fetch all branches from remote to potentially restore missing objects if they exist on the remote
git fetch origin refs/heads/*:refs/remotes/origin/* # Fetch all branches from remote to potentially restore missing objects if they exist on the remote
-
50% success git cat-file -p <hash> 2>/dev/null || (cd /path/to/backup && git cat-file -p <hash>) # Check if object exists in a backup repo; if so, copy the object file to .git/objects/ab/ directory using the hash prefix
git cat-file -p <hash> 2>/dev/null || (cd /path/to/backup && git cat-file -p <hash>) # Check if object exists in a backup repo; if so, copy the object file to .git/objects/ab/ directory using the hash prefix
中文步骤
git fetch origin refs/heads/*:refs/remotes/origin/* # Fetch all branches from remote to potentially restore missing objects if they exist on the remote
git cat-file -p <hash> 2>/dev/null || (cd /path/to/backup && git cat-file -p <hash>) # Check if object exists in a backup repo; if so, copy the object file to .git/objects/ab/ directory using the hash prefix
Dead Ends
Common approaches that don't work:
-
85% fail
Running git gc --aggressive without first recovering missing objects can permanently delete unreachable objects, making recovery impossible.
-
60% fail
Using git fsck --lost-found may find dangling objects but does not restore missing referenced objects; it just lists them.