{"thread":{"id":"26567","subject":"How to recovery a corrupted git repo","startedAt":"2011-02-21T07:50:09Z","lastAt":"2011-02-22T03:16:23Z","messageCount":8,"participants":["Ping Yin","Christian Couder","Axel Freyn","Matthieu Moy"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"161780","messageId":"AANLkTi=W3RckA=e-YwDJzELaEOAa+7P74V-G0G=bQhex@mail.gmail.com","threadId":"26567","inReplyTo":null,"subject":"How to recovery a corrupted git repo","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2011-02-21T07:50:09Z","receivedAt":"2011-02-21T07:50:09Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"I have a corrupted git repo, with \"git fsck\", it shows\n\nmissing blob b71eb55f2dbc97dafd4a769fc61f346e69a5e0af\nmissing blob 282035f3ae964e1e288f352c370be8edd11d3078\nmissing tree 3c20f556eecc476e3542cc522d46a62a4461fec6\nmissing blob f321b578edeb452358497e832815d6cae6b36886\nmissing commit 6d23f5084c975be637f7d748db82116bf84d3872\n\nAnd i also have a good backup repo. How can i recover the corrupted\nrepo with the backup repo?\n\nI can do a rsync or fresh \"git clone\", however, is there any git\nrelated commands to incrementally do this?\n\nbtw, \"git remote add and then git fetch\" doesn't work, it reports\n\nerror: refs/heads/bringup does not point to a valid object!\nerror: refs/heads/fsl_imx_r9.3 does not point to a valid object!\nerror: refs/heads/bringup does not point to a valid object!\nerror: refs/heads/fsl_imx_r9.3 does not point to a valid object!\nerror: refs/heads/bringup does not point to a valid object!\nerror: refs/heads/fsl_imx_r9.3 does not point to a valid object!\nerror: refs/heads/bringup does not point to a valid object!\nerror: refs/heads/fsl_imx_r9.3 does not point to a valid object!\nerror: missing object referenced by 'refs/tags/v2.6.32'\nerror: missing object referenced by 'refs/tags/v2.6.32-rc1'\nerror: missing object referenced by 'refs/tags/v2.6.32-rc2'\n"},{"id":"161782","messageId":"AANLkTimt1oR7nrhXmHugGooOAc3KTiDE6kQ3vGTznS9+@mail.gmail.com","threadId":"26567","inReplyTo":"AANLkTi=W3RckA=e-YwDJzELaEOAa+7P74V-G0G=bQhex@mail.gmail.com","subject":"Re: How to recovery a corrupted git repo","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2011-02-21T09:27:48Z","receivedAt":"2011-02-21T09:27:48Z","isPatch":false,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Mon, Feb 21, 2011 at 8:50 AM, Ping Yin <pkufranky@gmail.com> wrote:\n> I have a corrupted git repo, with \"git fsck\", it shows\n>\n> missing blob b71eb55f2dbc97dafd4a769fc61f346e69a5e0af\n> missing blob 282035f3ae964e1e288f352c370be8edd11d3078\n> missing tree 3c20f556eecc476e3542cc522d46a62a4461fec6\n> missing blob f321b578edeb452358497e832815d6cae6b36886\n> missing commit 6d23f5084c975be637f7d748db82116bf84d3872\n>\n> And i also have a good backup repo. How can i recover the corrupted\n> repo with the backup repo?\n\nPlease, have a look this FAQ entry:\n\nhttps://git.wiki.kernel.org/index.php/GitFaq#How_to_fix_a_broken_repository.3F\n\nAnd tell us what you did according to it.\n\nThanks,\nChristian.\n"},{"id":"161786","messageId":"20110221100454.GM22168@axel","threadId":"26567","inReplyTo":"AANLkTi=W3RckA=e-YwDJzELaEOAa+7P74V-G0G=bQhex@mail.gmail.com","subject":"Re: How to recovery a corrupted git repo","fromName":"Axel Freyn","fromEmail":"axel-freyn@gmx.de","sentAt":"2011-02-21T10:04:54Z","receivedAt":"2011-02-21T10:04:54Z","isPatch":false,"sender":{"key":"axel-freyn@gmx.de","avatar":null},"body":"Hi,\nOn Mon, Feb 21, 2011 at 03:50:09PM +0800, Ping Yin wrote:\n> I have a corrupted git repo, with \"git fsck\", it shows\n> \n> missing blob b71eb55f2dbc97dafd4a769fc61f346e69a5e0af\n> missing blob 282035f3ae964e1e288f352c370be8edd11d3078\n> missing tree 3c20f556eecc476e3542cc522d46a62a4461fec6\n> missing blob f321b578edeb452358497e832815d6cae6b36886\n> missing commit 6d23f5084c975be637f7d748db82116bf84d3872\n> \n> And i also have a good backup repo. How can i recover the corrupted\n> repo with the backup repo?\n> \n> I can do a rsync or fresh \"git clone\", however, is there any git\n> related commands to incrementally do this?\nI don't know whether there is a single git command to do it, but you can\ncopy those 5 objects \"by hand\": in your backup, you should have a\ndirectory .git/objects, where you have the files\n   b7/1eb55f2dbc97dafd4a769fc61f346e69a5e0af\n   28/2035f3ae964e1e288f352c370be8edd11d3078\n   3c/20f556eecc476e3542cc522d46a62a4461fec6\n   f3/21b578edeb452358497e832815d6cae6b36886\n   6d/23f5084c975be637f7d748db82116bf84d3872\n\nIt should be sufficient to just copy those files into the corrupted\nrepo.\n\nHowever if you packed the git-files in the backup (e.g. by running \"git\ngc\"), those objects might be found in a pack in .git/objects/pack.\nThe easiest ist probably to use git-unpack-objects to unpack the\nobjects, and then copy the 5 missing objects.\n\nAxel\n\nPS: Well, I'm using git and I like it -- but I'm no specialist; so first\ndo a backup, before you follow my proposal ;-)\n"},{"id":"161798","messageId":"AANLkTimAE4AOCYibrCRHaSJ-mHkrQm7yZbHNy3kWGj7-@mail.gmail.com","threadId":"26567","inReplyTo":"20110221100454.GM22168@axel","subject":"Re: How to recovery a corrupted git repo","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2011-02-21T10:11:44Z","receivedAt":"2011-02-21T10:11:44Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"Thanks, axel and Christian.\n\nI am just look for a simpler method. since i have a full backup,\nfinally , i do something like following\n\ngit clone --bare --reference bad-repo.git foo.com:good-repo.git repo.git\n\nOn Mon, Feb 21, 2011 at 6:04 PM, Axel Freyn <axel-freyn@gmx.de> wrote:\n> Hi,\n> On Mon, Feb 21, 2011 at 03:50:09PM +0800, Ping Yin wrote:\n>> I have a corrupted git repo, with \"git fsck\", it shows\n>>\n>> missing blob b71eb55f2dbc97dafd4a769fc61f346e69a5e0af\n>> missing blob 282035f3ae964e1e288f352c370be8edd11d3078\n>> missing tree 3c20f556eecc476e3542cc522d46a62a4461fec6\n>> missing blob f321b578edeb452358497e832815d6cae6b36886\n>> missing commit 6d23f5084c975be637f7d748db82116bf84d3872\n>>\n>> And i also have a good backup repo. How can i recover the corrupted\n>> repo with the backup repo?\n>>\n>> I can do a rsync or fresh \"git clone\", however, is there any git\n>> related commands to incrementally do this?\n> I don't know whether there is a single git command to do it, but you can\n> copy those 5 objects \"by hand\": in your backup, you should have a\n> directory .git/objects, where you have the files\n>   b7/1eb55f2dbc97dafd4a769fc61f346e69a5e0af\n>   28/2035f3ae964e1e288f352c370be8edd11d3078\n>   3c/20f556eecc476e3542cc522d46a62a4461fec6\n>   f3/21b578edeb452358497e832815d6cae6b36886\n>   6d/23f5084c975be637f7d748db82116bf84d3872\n>\n> It should be sufficient to just copy those files into the corrupted\n> repo.\n>\n> However if you packed the git-files in the backup (e.g. by running \"git\n> gc\"), those objects might be found in a pack in .git/objects/pack.\n> The easiest ist probably to use git-unpack-objects to unpack the\n> objects, and then copy the 5 missing objects.\n>\n> Axel\n>\n> PS: Well, I'm using git and I like it -- but I'm no specialist; so first\n> do a backup, before you follow my proposal ;-)\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n"},{"id":"161817","messageId":"vpqpqql1lw6.fsf@bauges.imag.fr","threadId":"26567","inReplyTo":"20110221100454.GM22168@axel","subject":"Re: How to recovery a corrupted git repo","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2011-02-21T14:51:21Z","receivedAt":"2011-02-21T14:51:21Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Axel Freyn <axel-freyn@gmx.de> writes:\n\n> I don't know whether there is a single git command to do it, but you can\n> copy those 5 objects \"by hand\": in your backup, you should have a\n> directory .git/objects, where you have the files\n>    b7/1eb55f2dbc97dafd4a769fc61f346e69a5e0af\n>    28/2035f3ae964e1e288f352c370be8edd11d3078\n>    3c/20f556eecc476e3542cc522d46a62a4461fec6\n>    f3/21b578edeb452358497e832815d6cae6b36886\n>    6d/23f5084c975be637f7d748db82116bf84d3872\n>\n> It should be sufficient to just copy those files into the corrupted\n> repo.\n>\n> However if you packed the git-files in the backup (e.g. by running \"git\n> gc\"), those objects might be found in a pack in .git/objects/pack.\n> The easiest ist probably to use git-unpack-objects to unpack the\n> objects, and then copy the 5 missing objects.\n\nThere's also the brute-force approach\n\nrsync $good_repo/.git/objects/ $bad_repo/.git/objects/\ncd $bad_repo\ngit gc\n\nNotice the absence of --delete in the rsync command: I'm just adding\nnew files in the $bad_repo, not deleting any (since files with\nidentical names must have identical content).\n\nThis will result in a lot of duplicates (objects found in several\npacks), but \"git gc\" should be able to remove them.\n\n(the notice about doing backups before also applies to my\nproposal ;-) )\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"161818","messageId":"AANLkTim-O+LR_r=N6y7Dcip8xQGcBVP2FiVhu22Zhysf@mail.gmail.com","threadId":"26567","inReplyTo":"vpqpqql1lw6.fsf@bauges.imag.fr","subject":"Re: How to recovery a corrupted git repo","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2011-02-21T15:03:55Z","receivedAt":"2011-02-21T15:03:55Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On Mon, Feb 21, 2011 at 10:51 PM, Matthieu Moy\n<Matthieu.Moy@grenoble-inp.fr> wrote:\n> Axel Freyn <axel-freyn@gmx.de> writes:\n>\n> There's also the brute-force approach\n>\n> rsync $good_repo/.git/objects/ $bad_repo/.git/objects/\n> cd $bad_repo\n> git gc\n>\n> Notice the absence of --delete in the rsync command: I'm just adding\n> new files in the $bad_repo, not deleting any (since files with\n> identical names must have identical content).\n\nThanks. This should be an applicable method. However, before rsyncing,\nthe pack should be unpacked first.\n"},{"id":"161821","messageId":"vpqipwds8uh.fsf@bauges.imag.fr","threadId":"26567","inReplyTo":"AANLkTim-O+LR_r=N6y7Dcip8xQGcBVP2FiVhu22Zhysf@mail.gmail.com","subject":"Re: How to recovery a corrupted git repo","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2011-02-21T15:31:02Z","receivedAt":"2011-02-21T15:31:02Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Ping Yin <pkufranky@gmail.com> writes:\n\n> Thanks. This should be an applicable method. However, before rsyncing,\n> the pack should be unpacked first.\n\nNo need. Just copying the pack files works too, and is way faster:\n\n/tmp/corrupted$ git fsck\nmissing commit 4815c2955d5863005edc4ff61c0de42e9609a920\ndangling tree c8b826f673e1f1edb0fb5dc58294148be06cd6cb\n/tmp/corrupted$ cp ../cloned/.git/objects/pack/pack-e34444a471a9cd3e6f2656b609ffa0d66cce1f9c.* .git/objects/pack/\n/tmp/corrupted$ git fsck                                                                                         \n/tmp/corrupted$ git gc\nCounting objects: 12, done.\nDelta compression using up to 2 threads.\nCompressing objects: 100% (4/4), done.\nWriting objects: 100% (12/12), done.\nTotal 12 (delta 0), reused 12 (delta 0)\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"161857","messageId":"AANLkTi=_nn84FcvvkhiKUJgVG4EkyYWoUYLctarh7a9L@mail.gmail.com","threadId":"26567","inReplyTo":"vpqipwds8uh.fsf@bauges.imag.fr","subject":"Re: How to recovery a corrupted git repo","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2011-02-22T03:16:23Z","receivedAt":"2011-02-22T03:16:23Z","isPatch":false,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On Mon, Feb 21, 2011 at 11:31 PM, Matthieu Moy\n<Matthieu.Moy@grenoble-inp.fr> wrote:\n> Ping Yin <pkufranky@gmail.com> writes:\n>\n>> Thanks. This should be an applicable method. However, before rsyncing,\n>> the pack should be unpacked first.\n>\n> No need. Just copying the pack files works too, and is way faster:\n>\n\nGreat, thanks.\n"}]}