Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Bad File Fatal Error

Git is saying that I need to pull before pushing to fast-forward but when I issue git pull origin master it returns this error:

fatal: failed to read object 12786e6d70d76ce47ecf69c30e4d0f994d1e2fc3: Invalid argument
fatal: The remote end hung up unexpectedly

I tried doing git cat-file -t 12786e6d70d76ce47ecf69c30e4d0f994d1e2fc3 but that returns 12786e6d70d76ce47ecf69c30e4d0f994d1e2fc3: bad file

How do I see which file is the bad one and how can I fix it?

EDIT: To the war chest!

EDIT 2: can I just delete everything and begin again?

like image 626
Chris Avatar asked Oct 05 '11 20:10

Chris


2 Answers

I deleted everything and pulled again. Couldn't get any work done so I had to do it :( Anyone who has any answers feel free to post.

like image 123
Chris Avatar answered Nov 15 '22 09:11

Chris


I experience the same problem. Luckily, In the same repository in the other machine can be found by the git cat-file <hash> command. However, that file got packed.

So, I use

git cat-file commit [hash] > make_magic.txt

and copied that file to the corrupt repository machine, run

cat make_magic.txt | git hash-object -w -t commit --stdin

And after that, this problem got resolved.

This is really better way than fetch from the beginning. I have 30,000 revisions and take at least 14 days to restore the repository from the beginning.

like image 27
scalopus Avatar answered Nov 15 '22 08:11

scalopus