* How to recovery a corrupted git repo
@ 2011-02-21 7:50 Ping Yin
2011-02-21 9:27 ` Christian Couder
2011-02-21 10:04 ` Axel Freyn
0 siblings, 2 replies; 8+ messages in thread
From: Ping Yin @ 2011-02-21 7:50 UTC (permalink / raw)
To: git mailing list
I have a corrupted git repo, with "git fsck", it shows
missing blob b71eb55f2dbc97dafd4a769fc61f346e69a5e0af
missing blob 282035f3ae964e1e288f352c370be8edd11d3078
missing tree 3c20f556eecc476e3542cc522d46a62a4461fec6
missing blob f321b578edeb452358497e832815d6cae6b36886
missing commit 6d23f5084c975be637f7d748db82116bf84d3872
And i also have a good backup repo. How can i recover the corrupted
repo with the backup repo?
I can do a rsync or fresh "git clone", however, is there any git
related commands to incrementally do this?
btw, "git remote add and then git fetch" doesn't work, it reports
error: refs/heads/bringup does not point to a valid object!
error: refs/heads/fsl_imx_r9.3 does not point to a valid object!
error: refs/heads/bringup does not point to a valid object!
error: refs/heads/fsl_imx_r9.3 does not point to a valid object!
error: refs/heads/bringup does not point to a valid object!
error: refs/heads/fsl_imx_r9.3 does not point to a valid object!
error: refs/heads/bringup does not point to a valid object!
error: refs/heads/fsl_imx_r9.3 does not point to a valid object!
error: missing object referenced by 'refs/tags/v2.6.32'
error: missing object referenced by 'refs/tags/v2.6.32-rc1'
error: missing object referenced by 'refs/tags/v2.6.32-rc2'
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to recovery a corrupted git repo
2011-02-21 7:50 How to recovery a corrupted git repo Ping Yin
@ 2011-02-21 9:27 ` Christian Couder
2011-02-21 10:04 ` Axel Freyn
1 sibling, 0 replies; 8+ messages in thread
From: Christian Couder @ 2011-02-21 9:27 UTC (permalink / raw)
To: Ping Yin; +Cc: git mailing list
On Mon, Feb 21, 2011 at 8:50 AM, Ping Yin <pkufranky@gmail.com> wrote:
> I have a corrupted git repo, with "git fsck", it shows
>
> missing blob b71eb55f2dbc97dafd4a769fc61f346e69a5e0af
> missing blob 282035f3ae964e1e288f352c370be8edd11d3078
> missing tree 3c20f556eecc476e3542cc522d46a62a4461fec6
> missing blob f321b578edeb452358497e832815d6cae6b36886
> missing commit 6d23f5084c975be637f7d748db82116bf84d3872
>
> And i also have a good backup repo. How can i recover the corrupted
> repo with the backup repo?
Please, have a look this FAQ entry:
https://git.wiki.kernel.org/index.php/GitFaq#How_to_fix_a_broken_repository.3F
And tell us what you did according to it.
Thanks,
Christian.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to recovery a corrupted git repo
2011-02-21 7:50 How to recovery a corrupted git repo Ping Yin
2011-02-21 9:27 ` Christian Couder
@ 2011-02-21 10:04 ` Axel Freyn
2011-02-21 10:11 ` Ping Yin
2011-02-21 14:51 ` Matthieu Moy
1 sibling, 2 replies; 8+ messages in thread
From: Axel Freyn @ 2011-02-21 10:04 UTC (permalink / raw)
To: git mailing list
Hi,
On Mon, Feb 21, 2011 at 03:50:09PM +0800, Ping Yin wrote:
> I have a corrupted git repo, with "git fsck", it shows
>
> missing blob b71eb55f2dbc97dafd4a769fc61f346e69a5e0af
> missing blob 282035f3ae964e1e288f352c370be8edd11d3078
> missing tree 3c20f556eecc476e3542cc522d46a62a4461fec6
> missing blob f321b578edeb452358497e832815d6cae6b36886
> missing commit 6d23f5084c975be637f7d748db82116bf84d3872
>
> And i also have a good backup repo. How can i recover the corrupted
> repo with the backup repo?
>
> I can do a rsync or fresh "git clone", however, is there any git
> related commands to incrementally do this?
I don't know whether there is a single git command to do it, but you can
copy those 5 objects "by hand": in your backup, you should have a
directory .git/objects, where you have the files
b7/1eb55f2dbc97dafd4a769fc61f346e69a5e0af
28/2035f3ae964e1e288f352c370be8edd11d3078
3c/20f556eecc476e3542cc522d46a62a4461fec6
f3/21b578edeb452358497e832815d6cae6b36886
6d/23f5084c975be637f7d748db82116bf84d3872
It should be sufficient to just copy those files into the corrupted
repo.
However if you packed the git-files in the backup (e.g. by running "git
gc"), those objects might be found in a pack in .git/objects/pack.
The easiest ist probably to use git-unpack-objects to unpack the
objects, and then copy the 5 missing objects.
Axel
PS: Well, I'm using git and I like it -- but I'm no specialist; so first
do a backup, before you follow my proposal ;-)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to recovery a corrupted git repo
2011-02-21 10:04 ` Axel Freyn
@ 2011-02-21 10:11 ` Ping Yin
2011-02-21 14:51 ` Matthieu Moy
1 sibling, 0 replies; 8+ messages in thread
From: Ping Yin @ 2011-02-21 10:11 UTC (permalink / raw)
To: git mailing list; +Cc: Axel Freyn, christian.couder
Thanks, axel and Christian.
I am just look for a simpler method. since i have a full backup,
finally , i do something like following
git clone --bare --reference bad-repo.git foo.com:good-repo.git repo.git
On Mon, Feb 21, 2011 at 6:04 PM, Axel Freyn <axel-freyn@gmx.de> wrote:
> Hi,
> On Mon, Feb 21, 2011 at 03:50:09PM +0800, Ping Yin wrote:
>> I have a corrupted git repo, with "git fsck", it shows
>>
>> missing blob b71eb55f2dbc97dafd4a769fc61f346e69a5e0af
>> missing blob 282035f3ae964e1e288f352c370be8edd11d3078
>> missing tree 3c20f556eecc476e3542cc522d46a62a4461fec6
>> missing blob f321b578edeb452358497e832815d6cae6b36886
>> missing commit 6d23f5084c975be637f7d748db82116bf84d3872
>>
>> And i also have a good backup repo. How can i recover the corrupted
>> repo with the backup repo?
>>
>> I can do a rsync or fresh "git clone", however, is there any git
>> related commands to incrementally do this?
> I don't know whether there is a single git command to do it, but you can
> copy those 5 objects "by hand": in your backup, you should have a
> directory .git/objects, where you have the files
> b7/1eb55f2dbc97dafd4a769fc61f346e69a5e0af
> 28/2035f3ae964e1e288f352c370be8edd11d3078
> 3c/20f556eecc476e3542cc522d46a62a4461fec6
> f3/21b578edeb452358497e832815d6cae6b36886
> 6d/23f5084c975be637f7d748db82116bf84d3872
>
> It should be sufficient to just copy those files into the corrupted
> repo.
>
> However if you packed the git-files in the backup (e.g. by running "git
> gc"), those objects might be found in a pack in .git/objects/pack.
> The easiest ist probably to use git-unpack-objects to unpack the
> objects, and then copy the 5 missing objects.
>
> Axel
>
> PS: Well, I'm using git and I like it -- but I'm no specialist; so first
> do a backup, before you follow my proposal ;-)
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to recovery a corrupted git repo
2011-02-21 10:04 ` Axel Freyn
2011-02-21 10:11 ` Ping Yin
@ 2011-02-21 14:51 ` Matthieu Moy
2011-02-21 15:03 ` Ping Yin
1 sibling, 1 reply; 8+ messages in thread
From: Matthieu Moy @ 2011-02-21 14:51 UTC (permalink / raw)
To: git mailing list
Axel Freyn <axel-freyn@gmx.de> writes:
> I don't know whether there is a single git command to do it, but you can
> copy those 5 objects "by hand": in your backup, you should have a
> directory .git/objects, where you have the files
> b7/1eb55f2dbc97dafd4a769fc61f346e69a5e0af
> 28/2035f3ae964e1e288f352c370be8edd11d3078
> 3c/20f556eecc476e3542cc522d46a62a4461fec6
> f3/21b578edeb452358497e832815d6cae6b36886
> 6d/23f5084c975be637f7d748db82116bf84d3872
>
> It should be sufficient to just copy those files into the corrupted
> repo.
>
> However if you packed the git-files in the backup (e.g. by running "git
> gc"), those objects might be found in a pack in .git/objects/pack.
> The easiest ist probably to use git-unpack-objects to unpack the
> objects, and then copy the 5 missing objects.
There's also the brute-force approach
rsync $good_repo/.git/objects/ $bad_repo/.git/objects/
cd $bad_repo
git gc
Notice the absence of --delete in the rsync command: I'm just adding
new files in the $bad_repo, not deleting any (since files with
identical names must have identical content).
This will result in a lot of duplicates (objects found in several
packs), but "git gc" should be able to remove them.
(the notice about doing backups before also applies to my
proposal ;-) )
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to recovery a corrupted git repo
2011-02-21 14:51 ` Matthieu Moy
@ 2011-02-21 15:03 ` Ping Yin
2011-02-21 15:31 ` Matthieu Moy
0 siblings, 1 reply; 8+ messages in thread
From: Ping Yin @ 2011-02-21 15:03 UTC (permalink / raw)
To: Matthieu Moy; +Cc: git mailing list
On Mon, Feb 21, 2011 at 10:51 PM, Matthieu Moy
<Matthieu.Moy@grenoble-inp.fr> wrote:
> Axel Freyn <axel-freyn@gmx.de> writes:
>
> There's also the brute-force approach
>
> rsync $good_repo/.git/objects/ $bad_repo/.git/objects/
> cd $bad_repo
> git gc
>
> Notice the absence of --delete in the rsync command: I'm just adding
> new files in the $bad_repo, not deleting any (since files with
> identical names must have identical content).
Thanks. This should be an applicable method. However, before rsyncing,
the pack should be unpacked first.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to recovery a corrupted git repo
2011-02-21 15:03 ` Ping Yin
@ 2011-02-21 15:31 ` Matthieu Moy
2011-02-22 3:16 ` Ping Yin
0 siblings, 1 reply; 8+ messages in thread
From: Matthieu Moy @ 2011-02-21 15:31 UTC (permalink / raw)
To: Ping Yin; +Cc: git mailing list
Ping Yin <pkufranky@gmail.com> writes:
> Thanks. This should be an applicable method. However, before rsyncing,
> the pack should be unpacked first.
No need. Just copying the pack files works too, and is way faster:
/tmp/corrupted$ git fsck
missing commit 4815c2955d5863005edc4ff61c0de42e9609a920
dangling tree c8b826f673e1f1edb0fb5dc58294148be06cd6cb
/tmp/corrupted$ cp ../cloned/.git/objects/pack/pack-e34444a471a9cd3e6f2656b609ffa0d66cce1f9c.* .git/objects/pack/
/tmp/corrupted$ git fsck
/tmp/corrupted$ git gc
Counting objects: 12, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (12/12), done.
Total 12 (delta 0), reused 12 (delta 0)
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to recovery a corrupted git repo
2011-02-21 15:31 ` Matthieu Moy
@ 2011-02-22 3:16 ` Ping Yin
0 siblings, 0 replies; 8+ messages in thread
From: Ping Yin @ 2011-02-22 3:16 UTC (permalink / raw)
To: Matthieu Moy; +Cc: git mailing list
On Mon, Feb 21, 2011 at 11:31 PM, Matthieu Moy
<Matthieu.Moy@grenoble-inp.fr> wrote:
> Ping Yin <pkufranky@gmail.com> writes:
>
>> Thanks. This should be an applicable method. However, before rsyncing,
>> the pack should be unpacked first.
>
> No need. Just copying the pack files works too, and is way faster:
>
Great, thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-02-22 3:16 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-21 7:50 How to recovery a corrupted git repo Ping Yin
2011-02-21 9:27 ` Christian Couder
2011-02-21 10:04 ` Axel Freyn
2011-02-21 10:11 ` Ping Yin
2011-02-21 14:51 ` Matthieu Moy
2011-02-21 15:03 ` Ping Yin
2011-02-21 15:31 ` Matthieu Moy
2011-02-22 3:16 ` Ping Yin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).