Xeoncross
Xeoncross

Reputation: 57184

Git - corrupted object?

My house just suffered a power-outage and now my git repo (which I was committing to when it happended) is reporting:

user@localhost$ git fsck
fatal: object 192e0282d23863ec80375a77011012ef8cb80f77 is corrupted

I can't commit because of this error. Pulling and fetching still seems to work fine.

user@localhost$ git commit
error: unable to find 192e0282d23863ec80375a77011012ef8cb80f77
fatal: 192e0282d23863ec80375a77011012ef8cb80f77 is not a valid object

I tried reseting it, but it didn't do anything

git reset HEAD 192e0282d23863ec80375a77011012ef8cb80f77
git gc

How do I fix this?

UPDATE: The files were still fine so I just cloned a new instance of the repo and manually moved the files over (Glad this wasn't the only repo instance!). However, I kept the broken repo so that I can try fixes posted here in case there is a next time.

Upvotes: 15

Views: 9767

Answers (2)

Karl Bielefeldt
Karl Bielefeldt

Reputation: 49008

Actually what you did with a new clone is probably the recommended way to fix it. No sense doing something complex if you don't have to. Those howtos are more for if you don't have the right version already in your working tree and don't have another clean copy.

Anyway, I think you wanted to reset to your last commit before the power outage, move the corrupted object out of your .git/objects, and try again. It looks like your tree might have been corrupted, which is why the howtos geared towards recovering blobs didn't help.

Upvotes: 1

yasouser
yasouser

Reputation: 5177

If you are looking for suggestions on how to recover from this, see this thread: How do you restore a corrupted object in a git repository (for newbies)?

Upvotes: 2

Related Questions