Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I deal with corrupted Git object files?

Tags:

git

I did a Git pull when I was near my quota, and as a result (so I think), got a corrupted file:

$ git pull walk dffbfa18916a9db95ef8fafc6d7d769c29a445aa fatal: object d4a0e7599494bfee2b5351113895b43c351496b3 is corrupted  $ git fsck --full bad sha1 file: .git/objects/66/b55c76947b1d38983e0944f1e6388c86f07a1b.temp fatal: object d4a0e7599494bfee2b5351113895b43c351496b3 is corrupted  $ git cat-file -t d4a0e7599494bfee2b5351113895b43c351496b3 error: unable to find d4a0e7599494bfee2b5351113895b43c351496b3 fatal: git cat-file d4a0e7599494bfee2b5351113895b43c351496b3: bad file 

How can I solve this corruption?

.git/objects/66/b55c76947b1d38983e0944f1e6388c86f07a1b.temp was zero bytes; deleting it did nothing to solve my problem (same errors).

like image 270
Mike Avatar asked Nov 06 '10 03:11

Mike


People also ask

What does git hash object do?

In its simplest form, git hash-object would take the content you handed to it and merely return the unique key that would be used to store it in your Git database. The -w option then tells the command to not simply return the key, but to write that object to the database.


1 Answers

You can use "find" for remove all files in the /objects directory with 0 in size with the command:

find .git/objects/ -size 0 -delete 

Backup is recommended.

like image 106
eid Avatar answered Oct 13 '22 10:10

eid