Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cant fix bad object HEAD error with git status

Tags:

git

My Battery died on my macbook when pushing my repo. Now I cannot run git status

$ git status
fatal: bad object HEAD
fatal: git status --porcelain failed

I've tried a few suggestions ive found for fixing bad object errors.

$ git fsck --full
dangling tree 65e856976b7aa7c73f15cd71defedb8a3d622a10

I've tried git prune and git prune-packed

I can still commit, stash, push, it appears to be just affecting git status

Andy ideas?

Thanks

like image 928
Rob Avatar asked Sep 11 '11 14:09

Rob


2 Answers

I guess you solved this problem already but i had this to and could fix it simply by run

git pull

This has resulted into a working condition. eventough your files are intact you should backup your local git directory and then run the git pull. after that you should be back in business.

If there are files deleted (it should not happen) you can copy them back over a working checkout and commit them from there.

like image 197
dasrecht Avatar answered Nov 12 '22 04:11

dasrecht


If your .git/HEAD is corrupted or points to a corrupted object, you can change it manually or by git checkout.

like image 34
wRAR Avatar answered Nov 12 '22 03:11

wRAR