Reputation: 7099
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
Upvotes: 16
Views: 41543
Reputation: 21
I had the same problem and this worked for me:
git fetch origin
git reset --soft origin/master
Upvotes: 1
Reputation: 674
This worked for me:
git fetch origin
git reset --hard origin/master
Upvotes: 1
Reputation: 711
This happened to me when I accidentally added my bin/ folder in an Eclipse Java project.
Using 'git pull' did not work for me.
I fixed it by:
Then I was able to 'git commit' and continue normally.
Upvotes: 2
Reputation: 450
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.
Upvotes: 33
Reputation: 111
Try add all of your modified files with git add filepath/file.ext
before the git status.
Upvotes: 0
Reputation: 25693
If your .git/HEAD
is corrupted or points to a corrupted object, you can change it manually or by git checkout
.
Upvotes: 2