开发者

How to replace corrupt Git objects with new ones created from my files, which are fine

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 co开发者_如何学运维rrupt objects and replace them with new objects built from the working copy of my app?

Git init didn't solve the problem.

Thanks!


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 :).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜