11

My app, in my filesystem, works just fine. All tests pass.

I'm a sole developer, using Git mostly to use Heroku as well as for backup.

Git has stopped working because of corrupt objects.

I'm getting errors that look like this:

steven-nobles-imac-200:drominay steven$ git push heroku master
error: inflate: data stream error (invalid distance too far back)
fatal: object 990ad2766afa2e2002eea265225ad160e73eacd2 is corrupted
error: pack-objects died with strange error

(And many other errors, all citing corrupted objects.)

How do I get Git to throw out the corrupt objects and replace them with new objects built from the working copy of my app?

Git init didn't solve the problem.

Thanks!

steven_noble
  • 4,133
  • 10
  • 44
  • 77

1 Answers1

10

You need to use git-fsck. The manual has details, but the gist is that git-fsck will make sure that the repository is internally consistent and list the missing objects, then you may use git hash-object -w <correct-file> to put the file given into the repository. If the file given to hash-object really is the one that was corrupt, your repository is now complete again :).

Updated to add: Git repair does the same things, but automagically :).

Andrew Aylett
  • 39,182
  • 5
  • 68
  • 95
  • But that doesn't work if the object in question is in a pack, right? How would I tell git to use the recovered object and not the one in the pack file? – Frederick Nord Jan 26 '14 at 13:29
  • @FrederickNord, the best option now (and I've edited my answer accordingly) is to use Joey Hess's git-repair. – Andrew Aylett Feb 19 '14 at 11:26