ProjectStack
git

fatal: bad object HEAD

Git can't resolve HEAD to a valid commit object. The HEAD pointer is either pointing to nothing (new repo with no commits) or the object store is corrupt.

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

  1. If no commits yet, make the first one: git add . && git commit -m 'Initial commit'
  2. Check if HEAD is pointing somewhere valid: cat .git/HEAD
  3. Verify the object store: git fsck --full
  4. If the repo is badly corrupt, clone a fresh copy from the remote: git clone <url>

Example

fatal: bad object HEAD

Running 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.