git · Git
The message
fatal: bad object 8a3f21c
What it means
The name you gave does not resolve to anything git can read: either the object is not in this repository, or it is there and damaged. It happens with a hash copied from another clone or from a shallow clone, with a truncated hash that is too short, or with a genuinely corrupted object after a disk problem. git fsck --full reports missing and broken objects read-only, and a hash from someone else needs a git fetch before the object exists here. If fsck does report corruption, re-cloning is faster and more certain than repairing — just copy your uncommitted files somewhere safe first.
The fix
git fsck --full- Printed by
- git
- Git
- 29
Almost every git error is a refusal that means "doing that from this state would lose something"; fatal: means git stopped without changing anything, and the hint: lines under the first line usually carry the actual remedy.
Reading an error message
- Read from the first line down. The lower you go the more it is about the tool’s internals; the cause is usually at the top.
- If there is a file and a line number, start there — not the top stack frame, but the topmost line that names a file you wrote.
- Search the message verbatim, but strip your own paths and variable names first; those are what stop the search from matching.
- The same condition is worded differently across tool versions. If results look wrong, add the version number to the query.
- Before pasting a fix, check what it throws away. Some of these cannot be undone.
Common questions
Q. What does “fatal: bad object 8a3f21c” mean?
The name you gave does not resolve to anything git can read: either the object is not in this repository, or it is there and damaged. It happens with a hash copied from another clone or from a shallow clone, with a truncated hash that is too short, or with a genuinely corrupted object after a disk problem. git fsck --full reports missing and broken objects read-only, and a hash from someone else needs a git fetch before the object exists here. If fsck does report corruption, re-cloning is faster and more certain than repairing — just copy your uncommitted files somewhere safe first.
Q. How do I fix it?
git fsck --full — before running it, check the explanation above for what this command discards.
Q. Which tool prints this?
git. It sits under Git, and the message runs to 4 words.