Skip to contentSkip to conversation

how to recovery corrupted git blob

DISCUSSION Yvonne Leroy 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi all,

I have a corrupted git repo.I've worked through the process
https://git.wiki.kernel.org/index.php/GitFaq#How_to_fix_a_broken_repository.3F
<https://git.wiki.kernel.org/index.php/GitFaq#How_to_fix_a_broken_repository.3F>
but still have some problem.

1- at the beginning, with "git fsck --full", it showed:

Checking object directories: 100% (256/256), done. dangling blob 13dcdade560f11e8bc2d865a0d4a1a1133e5b132 dangling tree 5c9e60742ff24bb19fd73a8c1c879c4e10951b78 missing blob 96209289c92e6ef0e6beb6ec1644f93981b00829 dangling blob f61e50d30fa95683067aa2a50380e3dd7033e6dd dangling tree 95b5c5eeec8ac9359a31b268b938c142443d783a dangling commit d41b93032b34e380030207b5c8f502c6ecfd56ad dangling blob dae58bd96104c1292a20e1b8c8c948025e2e8924 missing blob e187557d07857b974ea51e3ea962ac120cfc9488

2- since I don't have a "broken link" message,I use $ git commit -m "fixing git repo",it said:

error: invalid object 100644 e187557d07857b974ea51e3ea962ac120cfc9488 for 'proje
ct5/css/style.css'
error: Error building trees

3- and then I use $ git hash-object -w project5/css/style.css, it said:

git hash-object -w project5/css/style.css
f61e50d30fa95683067aa2a50380e3dd7033e6dd

the result is not the missing blob
(e187557d07857b974ea51e3ea962ac120cfc9488)

4- so I use $ git log --raw --all --full-history -- project5/css/style.css, it said:

commit 7b5314a110b8e2835f7f3d068072429be87be574
Merge: ec5e609 e415bb6
Author: Yvonne Leroy <[email protected]>
Date: Sun Dec 15 23:40:41 2013 +0800

WIP on master: ec5e609 list

commit e415bb6d51ee05d60055d89f2bf63ccb32f4c12c

Author: Yvonne Leroy <[email protected]>
Date:   Sun Dec 15 23:40:39 2013 +0800 

index on master: ec5e609 list

:100644 100644 595691a... e187557... M project5/css/style.css

commit ec76f78324632c3eebd874a724a9ebfe7d1f22ec

Author: Yvonne Leroy <[email protected]>
Date:   Sat Dec 7 14:48:37 2013 +0800 

nav view

:000000 100644 0000000... 595691a... A project5/css/style.css

5-here is my problem,how can I looking at those older and newer versions(Could someone point me to which commands I should look at? Still new to git:))
so that I can use the next step git hash-object -w <recreated-file>
and could someone tell me what should I do with <recreated-file>,is it still project5/css/style.css ?

Thanks in advance,
Yvonne.

--
View this message in context: http://git.661346.n2.nabble.com/how-to-recovery-corrupted-git-blob-tp7601221.html
Sent from the git mailing list archive at Nabble.com.

#1 lore raw

Hi,

Quoted 2 lines · Yvonne Leroy

1- at the beginning, with "git fsck --full", it showed:

[...]

Quoted 1 line

missing blob e187557d07857b974ea51e3ea962ac120cfc9488

[...]

Quoted 7 lines

commit e415bb6d51ee05d60055d89f2bf63ccb32f4c12c

Author: Yvonne Leroy <[email protected]>
Date:   Sun Dec 15 23:40:39 2013 +0800

index on master: ec5e609 list

:100644 100644 595691a... e187557... M project5/css/style.css

The above show you that the previous version of the blob was 595691a. But in the output you showed there was no line with something like:

Quoted 1 line

:100644 100644 e187557... <newversion>... M project5/css/style.css

So we know the previous version but not the subsequent version of that file.

Could you check again that there is no subsequent version with something like:

git log --raw --all --full-history -- project5/css/style.css | grep e187557

?

[...]

Quoted 3 lines

5-here is my problem,how can I looking at those older and newer versions(Could someone point me to which commands I should look at? Still new to git:))

You can use "git cat-file blob 595691a" to look at the previous version.

Quoted 3 lines

so that I can use the next step git hash-object -w <recreated-file>
and could someone tell me what should I do with <recreated-file>,is it still project5/css/style.css ?

If "git hash-object -w <recreated-file>" results in e187557d07857b974ea51e3ea962ac120cfc9488
then it means that the missing blob was successfully rewritten into your git repo, so everything should be fine after that. To make sure you can run "git fsck" again.

Note that you are trying to recreate the missing blob, but in my opinion before trying to do that you should probably try to find the missing blob in another repo. The log above showed that the missing blob was created on the 15th of December (Sun Dec 15 23:40:39 2013 +0800). Haven't you pushed your repo somewhere since that day? If you did push, it's probably easier to get the missing blob from where you pushed.

Regards,
Christian.