Git: bad object HEAD

I’ve never had this error before and I also didn’t know what could have caused this issue. In my specific case I could no longer use the commands status and log.

# git status
fatal: bad object HEAD
# git log
fatal: bad object HEAD

Quick fix

It can’t be easier than a simple pull. Your head should be fine afterwards.

# git pull
error: refs/heads/master does not point to a valid object!
error: refs/remotes/origin/HEAD does not point to a valid object!
error: refs/remotes/origin/master does not point to a valid object!
error: refs/heads/master does not point to a valid object!
error: refs/remotes/origin/HEAD does not point to a valid object!
error: refs/remotes/origin/master does not point to a valid object!
error: refs/heads/master does not point to a valid object!
error: refs/remotes/origin/HEAD does not point to a valid object!
error: refs/remotes/origin/master does not point to a valid object!
error: refs/heads/master does not point to a valid object!
error: refs/remotes/origin/HEAD does not point to a valid object!
error: refs/remotes/origin/master does not point to a valid object!
remote: Reusing existing pack: 397, done.
remote: Total 397 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (397/397), 1.57 MiB | 1.11 MiB/s, done.
Resolving deltas: 100% (97/97), done.
From github.com:slopjong/Snippets
 * [new branch]      master     -> origin/master
Already up-to-date.
# git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD ..." to unstage)

	new file:   web/horizontal-angular-menu/index.html

Other fixes

If git pull didn’t work for you, try the following options:

  • git fsck --full
  • .git/HEAD is corrupt and needs to be fixed manually or by git checkout .
  • you committed binaries e.g. Java’s .class files

1 Comment

  1. RitchieF

    You’re not syncing your repository with another machine/folder do you? Had the same problem when I had the brilliant idea that it would be great two have both of my machines with all my repos in sync.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>