Common causes
- You initialized a new repository but haven't made the first commit yet
- The .git/objects directory has corrupt or missing files
- You deleted commits with git reset and the repo is now in an inconsistent state
- A filesystem issue or interrupted write corrupted the object store
How to fix it
- If no commits yet, make the first one: git add . && git commit -m 'Initial commit'
- Check if HEAD is pointing somewhere valid: cat .git/HEAD
- Verify the object store: git fsck --full
- If the repo is badly corrupt, clone a fresh copy from the remote: git clone <url>
Example
fatal: bad object HEADRunning git log or git show on a new repo before the first commit
Have a different error?
Paste any error message into the Error Translator to get an instant explanation.
