Git Bad File Error

Git says I need to pull before clicking 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 returns 12786e6d70d76ce47ecf69c30e4d0f994d1e2fc3: bad file

How do I see which file is bad and how to fix it?

EDIT: Into a military chest!

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

+6
source share
5 answers

I deleted everything and pulled it out again. Could not do any work, so I had to do it :( Anyone who has the answers is not shy about posting.

+5
source

I have the same problem. Fortunately, in the same repository on another computer, you can find the git cat-file <hash> command. However, this file has been packaged.

So i use

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

and copied this file to a corrupt repository, run

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

And after that this problem was solved.

This is really a better way than sampling from the start. I have 30,000 fixes and it takes at least 14 days to restore the repository from the start.

+2
source

Have you tried git clean && git pull ? You might want to back up your raw files before issuing commands.

0
source

When I get The remote end hung up unexpectedly (on Windows), this usually means that the network drive containing origin is not mounted.

Can you exclude git only connection problems?

0
source

"git checkout -." from the project root directory usually fixes such errors for me if connection / authentication works.

0
source

Source: https://habr.com/ru/post/898703/


All Articles