{"thread":{"id":"27671","subject":"corrupted Git repository","startedAt":"2011-06-21T06:58:50Z","lastAt":"2011-06-21T14:59:18Z","messageCount":11,"participants":["Kasra Khosoussi","Michael J Gruber","Ilari Liusvaara","Johannes Sixt","Carlos Martín Nieto"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"170357","messageId":"BANLkTi=A=DpyfNwEeSd6N6ibCsA5qh_NPQ@mail.gmail.com","threadId":"27671","inReplyTo":null,"subject":"corrupted Git repository","fromName":"Kasra Khosoussi","fromEmail":"kasra.mail@gmail.com","sentAt":"2011-06-21T06:58:50Z","receivedAt":"2011-06-21T06:58:50Z","isPatch":false,"sender":{"key":"kasra.mail@gmail.com","avatar":"https://gravatar.com/avatar/af0f1876dd846d89666aa7953937fa0c048a8a27ac5987bd6c80bf5722aca688?d=mp&s=160"},"body":"Hi all,\n\nMy thesis repository is corrupted and I don't have any recent backup\n(my files are OK, but the history is lost). I've seen the recovery\nexamples in the manual, but I believe my case is somehow different.\nThe repository is linear.\n\n1- At the beginning, git status/log/fsck -full said:\n\n> fatal: object 0a83757505387aacc2fd36b3c996729e6bf9d6e5 is corrupted\n\nand there was an empty file in .git/objects/01/8375... .\n\n2- If I move the corrupted object, git fsck --ful would return this:\n\n> error: HEAD: invalid sha1 pointer 0a83757505387aacc2fd36b3c996729e6bf9d6e5\n> error: refs/heads/master does not point to a valid object!\n> dangling tree 06f388dc60cfb014b5e1f70ecdaa568efe6bd0fa\n> dangling tree d86f8c75e836e13b6e0336361641223f48fde722\n\n3- I guess I have to edit refs/heads/master and replace the corrupted\nsha1 with another hash, but I'm not sure how I can find the proper\ncommit (e.g.,maybe by using find -mtime?).\n\nThanks in advance,\n\n-Kasra\n"},{"id":"170360","messageId":"4E005404.5010901@drmicha.warpmail.net","threadId":"27671","inReplyTo":"BANLkTi=A=DpyfNwEeSd6N6ibCsA5qh_NPQ@mail.gmail.com","subject":"Re: corrupted Git repository","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2011-06-21T08:19:16Z","receivedAt":"2011-06-21T08:19:16Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Kasra Khosoussi venit, vidit, dixit 21.06.2011 08:58:\n> Hi all,\n> \n> My thesis repository is corrupted and I don't have any recent backup\n> (my files are OK, but the history is lost). I've seen the recovery\n\nBackup now!\nI guess you've done that meanwhile anyways, but it's important before\nany recovery attempts.\n\nIs your reflog OK, i.e. do you get proper output from \"git reflog\" or\n\"git log -g\"?\n\n> examples in the manual, but I believe my case is somehow different.\n> The repository is linear.\n> \n> 1- At the beginning, git status/log/fsck -full said:\n> \n>> fatal: object 0a83757505387aacc2fd36b3c996729e6bf9d6e5 is corrupted\n\nHopefully and probably only the most recent commit (the one above) is\nlost, not all of our history.\n\n> \n> and there was an empty file in .git/objects/01/8375... .\n\n.git/objects/0a83... probably\n\n> \n> 2- If I move the corrupted object, git fsck --ful would return this:\n> \n>> error: HEAD: invalid sha1 pointer 0a83757505387aacc2fd36b3c996729e6bf9d6e5\n>> error: refs/heads/master does not point to a valid object!\n>> dangling tree 06f388dc60cfb014b5e1f70ecdaa568efe6bd0fa\n>> dangling tree d86f8c75e836e13b6e0336361641223f48fde722\n> \n> 3- I guess I have to edit refs/heads/master and replace the corrupted\n> sha1 with another hash, but I'm not sure how I can find the proper\n> commit (e.g.,maybe by using find -mtime?).\n> \n> Thanks in advance,\n> \n> -Kasra\n\nThe reflog will give you the previous value of HEAD. You can set\nrefs/heads/master to that (git update-ref) and then rebuild the lost\ncommit on top of that (assuming only one commit is lost). The dangling\ntrees are not necessarily due to the corrupt commit object. Have you\nchanged any files since the corrupt commit? Do you remember which files\nyou changed in that commit?\n\nMichael\n"},{"id":"170361","messageId":"BANLkTi=WVTGcGkUXjkuPYcxhMY0a5KPB7g@mail.gmail.com","threadId":"27671","inReplyTo":"4E005404.5010901@drmicha.warpmail.net","subject":"Re: corrupted Git repository","fromName":"Kasra Khosoussi","fromEmail":"kasra.mail@gmail.com","sentAt":"2011-06-21T09:30:36Z","receivedAt":"2011-06-21T09:30:36Z","isPatch":false,"sender":{"key":"kasra.mail@gmail.com","avatar":"https://gravatar.com/avatar/af0f1876dd846d89666aa7953937fa0c048a8a27ac5987bd6c80bf5722aca688?d=mp&s=160"},"body":"> Backup now!\n> I guess you've done that meanwhile anyways, but it's important before\n> any recovery attempts.\n\nYes, I've done that.\n\n> Is your reflog OK, i.e. do you get proper output from \"git reflog\" or\n> \"git log -g\"?\n\nNo. Before moving the corrupted object git reflog would return:\nfatal: object 0a83757505387aacc2fd36b3c996729e6bf9d6e5 is corrupted\n\nand after moving the file it would say:\nfatal: bad object HEAD\n\n> .git/objects/0a83... probably\n\nYes, it was a typo.\n\n> The reflog will give you the previous value of HEAD. You can set\n> refs/heads/master to that (git update-ref) and then rebuild the lost\n> commit on top of that (assuming only one commit is lost). The dangling\n> trees are not necessarily due to the corrupt commit object. Have you\n> changed any files since the corrupt commit?\n\nYes, I've changed two files after the last commit (I knew about the\ncorruption when I was just about to commit the changes).\n\n> Do you remember which files\n> you changed in that commit?\n>\n> Michael\n\nIf the the corrupt commit is the last one, yes.\n\nThanks.\n\n-- Kasra\n"},{"id":"170362","messageId":"4E006682.80101@drmicha.warpmail.net","threadId":"27671","inReplyTo":"BANLkTi=WVTGcGkUXjkuPYcxhMY0a5KPB7g@mail.gmail.com","subject":"Re: corrupted Git repository","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2011-06-21T09:38:10Z","receivedAt":"2011-06-21T09:38:10Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Kasra Khosoussi venit, vidit, dixit 21.06.2011 11:30:\n>> Backup now!\n>> I guess you've done that meanwhile anyways, but it's important before\n>> any recovery attempts.\n> \n> Yes, I've done that.\n> \n>> Is your reflog OK, i.e. do you get proper output from \"git reflog\" or\n>> \"git log -g\"?\n> \n> No. Before moving the corrupted object git reflog would return:\n> fatal: object 0a83757505387aacc2fd36b3c996729e6bf9d6e5 is corrupted\n> \n> and after moving the file it would say:\n> fatal: bad object HEAD\n\nOh yes, stupid me, sorry. \"git reflog\" tries to parse HEAD. But you can\nlook at the file directly:\n\ntail .git/logs/HEAD\ntail .git/logs/refs/heads/master\n\netc. show you what's been going on with those refs lately.\n\nYou should be able to pick the the sha1 before the corrupt one from that\nand do things like \"git log that_sha1\" if only the most recent commit is\ncorrupt.\n\nMichael\n"},{"id":"170363","messageId":"BANLkTi=GdEfXnAGa6V-33wqX2C-2x-9JQQ@mail.gmail.com","threadId":"27671","inReplyTo":"4E006682.80101@drmicha.warpmail.net","subject":"Re: corrupted Git repository","fromName":"Kasra Khosoussi","fromEmail":"kasra.mail@gmail.com","sentAt":"2011-06-21T10:10:47Z","receivedAt":"2011-06-21T10:10:47Z","isPatch":false,"sender":{"key":"kasra.mail@gmail.com","avatar":"https://gravatar.com/avatar/af0f1876dd846d89666aa7953937fa0c048a8a27ac5987bd6c80bf5722aca688?d=mp&s=160"},"body":"Thanks for your help.\n\nI used update-ref and changed refs/heads/master to the sha1 of\nprevious commit. Then I commit the changes. Everything seems fine now\nexcept (as you previously mentioned), git fsck -full complains about\ndangling trees. Is it critical?\n\n-Kasra\n\nOn Tue, Jun 21, 2011 at 2:08 PM, Michael J Gruber\n<git@drmicha.warpmail.net> wrote:\n> Kasra Khosoussi venit, vidit, dixit 21.06.2011 11:30:\n>>> Backup now!\n>>> I guess you've done that meanwhile anyways, but it's important before\n>>> any recovery attempts.\n>>\n>> Yes, I've done that.\n>>\n>>> Is your reflog OK, i.e. do you get proper output from \"git reflog\" or\n>>> \"git log -g\"?\n>>\n>> No. Before moving the corrupted object git reflog would return:\n>> fatal: object 0a83757505387aacc2fd36b3c996729e6bf9d6e5 is corrupted\n>>\n>> and after moving the file it would say:\n>> fatal: bad object HEAD\n>\n> Oh yes, stupid me, sorry. \"git reflog\" tries to parse HEAD. But you can\n> look at the file directly:\n>\n> tail .git/logs/HEAD\n> tail .git/logs/refs/heads/master\n>\n> etc. show you what's been going on with those refs lately.\n>\n> You should be able to pick the the sha1 before the corrupt one from that\n> and do things like \"git log that_sha1\" if only the most recent commit is\n> corrupt.\n>\n> Michael\n>\n"},{"id":"170365","messageId":"20110621103947.GA30147@LK-Perkele-VI.localdomain","threadId":"27671","inReplyTo":"BANLkTi=GdEfXnAGa6V-33wqX2C-2x-9JQQ@mail.gmail.com","subject":"Re: corrupted Git repository","fromName":"Ilari Liusvaara","fromEmail":"ilari.liusvaara@elisanet.fi","sentAt":"2011-06-21T10:39:47Z","receivedAt":"2011-06-21T10:39:47Z","isPatch":false,"sender":{"key":"ilari.liusvaara@elisanet.fi","avatar":null},"body":"On Tue, Jun 21, 2011 at 02:40:47PM +0430, Kasra Khosoussi wrote:\n> Thanks for your help.\n> \n> I used update-ref and changed refs/heads/master to the sha1 of\n> previous commit. Then I commit the changes. Everything seems fine now\n> except (as you previously mentioned), git fsck -full complains about\n> dangling trees. Is it critical?\n \nDangling trees are normal. They are not errors.\n\n-Ilari\n"},{"id":"170364","messageId":"BANLkTimQarJ=m7OSVg-uC_48eh3PxQ3cKw@mail.gmail.com","threadId":"27671","inReplyTo":"20110621103947.GA30147@LK-Perkele-VI.localdomain","subject":"Re: corrupted Git repository","fromName":"Kasra Khosoussi","fromEmail":"kasra.mail@gmail.com","sentAt":"2011-06-21T10:40:01Z","receivedAt":"2011-06-21T10:40:01Z","isPatch":false,"sender":{"key":"kasra.mail@gmail.com","avatar":"https://gravatar.com/avatar/af0f1876dd846d89666aa7953937fa0c048a8a27ac5987bd6c80bf5722aca688?d=mp&s=160"},"body":"Thanks for your help.\n\nOn Tue, Jun 21, 2011 at 3:09 PM, Ilari Liusvaara\n<ilari.liusvaara@elisanet.fi> wrote:\n> On Tue, Jun 21, 2011 at 02:40:47PM +0430, Kasra Khosoussi wrote:\n>> Thanks for your help.\n>>\n>> I used update-ref and changed refs/heads/master to the sha1 of\n>> previous commit. Then I commit the changes. Everything seems fine now\n>> except (as you previously mentioned), git fsck -full complains about\n>> dangling trees. Is it critical?\n>\n> Dangling trees are normal. They are not errors.\n>\n> -Ilari\n>\n"},{"id":"170381","messageId":"4E00A0E1.8000006@viscovery.net","threadId":"27671","inReplyTo":"BANLkTi=GdEfXnAGa6V-33wqX2C-2x-9JQQ@mail.gmail.com","subject":"Re: corrupted Git repository","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2011-06-21T13:47:13Z","receivedAt":"2011-06-21T13:47:13Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 6/21/2011 12:10, schrieb Kasra Khosoussi:\n> Everything seems fine now\n\nBut it would still be good to know how the corruption could have happened.\nDo you have any clues?\n\nDisk full?\nCtrl-C in the middle of a git operation?\nSome cron script interference (unlikely)?\nPermission problems (unlikely)?\nNetworking problems (only if the repository is on a network mount)?\nSomething else?\n\n-- Hannes\n"},{"id":"170383","messageId":"BANLkTi=6jt7Z3fvK++ontW=F9AJbmEr9Qg@mail.gmail.com","threadId":"27671","inReplyTo":"4E00A0E1.8000006@viscovery.net","subject":"Re: corrupted Git repository","fromName":"Kasra Khosoussi","fromEmail":"kasra.mail@gmail.com","sentAt":"2011-06-21T14:26:55Z","receivedAt":"2011-06-21T14:26:55Z","isPatch":false,"sender":{"key":"kasra.mail@gmail.com","avatar":"https://gravatar.com/avatar/af0f1876dd846d89666aa7953937fa0c048a8a27ac5987bd6c80bf5722aca688?d=mp&s=160"},"body":"Good question! Actually I have no idea!\n\nIt was fine yesterday. I had to leave home so I just shutdown my\nnetbook (I just issued the command and closed the lid). Files were\nopen in my editor but I'm sure that there were no Git processes\nrunning at the time. The battery was empty this morning, so my best\nguess is that the halt operation was somehow failed, but I think it\ncan not explain the corruption.\n\nAny idea?\n\n-Kasra\n\nOn Tue, Jun 21, 2011 at 6:17 PM, Johannes Sixt <j.sixt@viscovery.net> wrote:\n> Am 6/21/2011 12:10, schrieb Kasra Khosoussi:\n>> Everything seems fine now\n>\n> But it would still be good to know how the corruption could have happened.\n> Do you have any clues?\n>\n> Disk full?\n> Ctrl-C in the middle of a git operation?\n> Some cron script interference (unlikely)?\n> Permission problems (unlikely)?\n> Networking problems (only if the repository is on a network mount)?\n> Something else?\n>\n> -- Hannes\n>\n"},{"id":"170384","messageId":"20110621143211.GA4910@bee.lab.cmartin.tk","threadId":"27671","inReplyTo":"BANLkTi=6jt7Z3fvK++ontW=F9AJbmEr9Qg@mail.gmail.com","subject":"Re: corrupted Git repository","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2011-06-21T14:32:11Z","receivedAt":"2011-06-21T14:32:11Z","isPatch":false,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"On Tue, Jun 21, 2011 at 06:56:55PM +0430, Kasra Khosoussi wrote:\n> Good question! Actually I have no idea!\n> \n> It was fine yesterday. I had to leave home so I just shutdown my\n> netbook (I just issued the command and closed the lid). Files were\n> open in my editor but I'm sure that there were no Git processes\n> running at the time. The battery was empty this morning, so my best\n> guess is that the halt operation was somehow failed, but I think it\n> can not explain the corruption.\n> \n> Any idea?\n\nDoes your computer actually shutdown or suspend? It could be that the\nfiles still hadn't been flushed to disc when the battery ran out, but\nthat is unlikely if it did keep running.\n\nCheers,\n   cmn\n"},{"id":"170388","messageId":"BANLkTinaMfD4YG_Rx1OhixoX7XuPmaiaMQ@mail.gmail.com","threadId":"27671","inReplyTo":"20110621143211.GA4910@bee.lab.cmartin.tk","subject":"Re: corrupted Git repository","fromName":"Kasra Khosoussi","fromEmail":"kasra.mail@gmail.com","sentAt":"2011-06-21T14:59:18Z","receivedAt":"2011-06-21T14:59:18Z","isPatch":false,"sender":{"key":"kasra.mail@gmail.com","avatar":"https://gravatar.com/avatar/af0f1876dd846d89666aa7953937fa0c048a8a27ac5987bd6c80bf5722aca688?d=mp&s=160"},"body":"The battery was not empty when I issued the shutdown command, so there\nshould have been plenty of time before it ran out.\n\n-Kasra\n\nOn Tue, Jun 21, 2011 at 7:02 PM, Carlos Martín Nieto <cmn@elego.de> wrote:\n> On Tue, Jun 21, 2011 at 06:56:55PM +0430, Kasra Khosoussi wrote:\n>> Good question! Actually I have no idea!\n>>\n>> It was fine yesterday. I had to leave home so I just shutdown my\n>> netbook (I just issued the command and closed the lid). Files were\n>> open in my editor but I'm sure that there were no Git processes\n>> running at the time. The battery was empty this morning, so my best\n>> guess is that the halt operation was somehow failed, but I think it\n>> can not explain the corruption.\n>>\n>> Any idea?\n>\n> Does your computer actually shutdown or suspend? It could be that the\n> files still hadn't been flushed to disc when the battery ran out, but\n> that is unlikely if it did keep running.\n>\n> Cheers,\n>   cmn\n>\n"}]}