I tried to run git push and got a corruption error:
% git push
Counting objects: 62, done.
Delta compression using up to 2 threads.
error: corrupt loose object 'f2310668fe335b36c513e50fcd99744e8fd5c2e0'
fatal: object f2310668fe335b36c513e50fcd99744e8fd5c2e0 is corrupted
error: pack-objects died with strange error
This hangs on the last line until I hit Ctrl+C.
I read that running git gc might help, so I did that and got a similar error:
% git gc
Counting objects: 493, done.
Delta compression using up to 2 threads.
error: corrupt loose object 'f2310668fe335b36c513e50fcd99744e8fd5c2e0'
fatal: object f2310668fe335b36c513e50fcd99744e8fd5c2e0 is corrupted
error: failed to run repack
What should I do to fix this?
Clone a backup of your repository. If the corrupted object id is $OBJECTID, do this:
In new repository:
Move those two new files to the old repository
In corrupt repository, move away your corrupt object:
This should write the object into git’s database, and output $OBJECTID to STDOUT. If it outputs some other SHA1 id, you have made a mistake and you should delete that wrong object.