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.
git-repair can repair various forms of damage to git repositories. It is a complement to git fsck, which finds problems, but does not fix them. As well as avoiding the need to rm -rf a damaged repository and re-clone, using git-repair can help rescue commits you've made to the damaged repository and not yet pushed out.
To start update of all repositories, go to the Git Integration for Jira app Git Repositories tab then click Reindex All button.
A Git command needs to be run on a specific repository, so this error typically occurs when a Git command is run in a directory that Git doesn't know about. In these cases, the fix is to make sure that you are both working in the correct folder and that you set up your repository right.
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)?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With