{"thread":{"id":"15778","subject":"Broken index file - any hope?","startedAt":"2008-10-03T21:51:37Z","lastAt":"2008-10-04T03:08:48Z","messageCount":6,"participants":["Jonas Schneider","Shawn O. Pearce","Jeff Whiteside","Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"92279","messageId":"48E693E9.708@gmx.de","threadId":"15778","inReplyTo":null,"subject":"Broken index file - any hope?","fromName":"Jonas Schneider","fromEmail":"jonasschneider@gmx.de","sentAt":"2008-10-03T21:51:37Z","receivedAt":"2008-10-03T21:51:37Z","isPatch":false,"sender":{"key":"jonasschneider@gmx.de","avatar":null},"body":"Hey guys,\n\nI come from the Ruby on Rails world, where Git is now spreading like ... \nduh, something fast.\nToday I sadly lost my complete .git directory, only the working copy was \nleft behind.\nI reconstructed the directory, but the index file seems to be corrupt, \nevery command just tells me about a bad signature.\nI hope the rest of the repository is intanct. If it is, is there any \nchance to restore/rebuild that index file from the rest?\nI don't have an idea of the internals of git, but I know the objects are \nstored in different files, and maybe on top of that\nI could rebuild the index file.\n\nAny hope?\nThanks,\n--Jonas Schneider\n"},{"id":"92280","messageId":"20081003215319.GX21310@spearce.org","threadId":"15778","inReplyTo":"48E693E9.708@gmx.de","subject":"Re: Broken index file - any hope?","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-10-03T21:53:19Z","receivedAt":"2008-10-03T21:53:19Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jonas Schneider <JonasSchneider@gmx.de> wrote:\n> I come from the Ruby on Rails world, where Git is now spreading like ...  \n> duh, something fast.\n> Today I sadly lost my complete .git directory, only the working copy was  \n> left behind.\n> I reconstructed the directory, but the index file seems to be corrupt,  \n> every command just tells me about a bad signature.\n> I hope the rest of the repository is intanct. If it is, is there any  \n> chance to restore/rebuild that index file from the rest?\n> I don't have an idea of the internals of git, but I know the objects are  \n> stored in different files, and maybe on top of that\n> I could rebuild the index file.\n\nGive this a shot:\n\n  git read-tree --reset HEAD\n  git status\n\nat worst you lose staged changes.  At best you recover the index\nfile.\n\n-- \nShawn.\n"},{"id":"92281","messageId":"48E696CB.6040405@gmx.de","threadId":"15778","inReplyTo":"20081003215319.GX21310@spearce.org","subject":"Re: Broken index file - any hope?","fromName":"Jonas Schneider","fromEmail":"jonasschneider@gmx.de","sentAt":"2008-10-03T22:03:55Z","receivedAt":"2008-10-03T22:03:55Z","isPatch":false,"sender":{"key":"jonasschneider@gmx.de","avatar":null},"body":"Shawn O. Pearce schrieb:\n>   git read-tree --reset HEAD\nSadly, this doesnt help. I still get the same error.\nBut, if I remove the corrupt index file, I get this:\n\nfatal: just how do you expect me to merge 0 trees?\n\nDoes not look like a good sign :/\nAre all my branches (branch==tree?) gone? (okay, werent that much)\n\nThanks anyway :)\n-- Jonas\n"},{"id":"92282","messageId":"20081003220750.GY21310@spearce.org","threadId":"15778","inReplyTo":"48E696CB.6040405@gmx.de","subject":"Re: Broken index file - any hope?","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-10-03T22:07:50Z","receivedAt":"2008-10-03T22:07:50Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Jonas Schneider <JonasSchneider@gmx.de> wrote:\n> Shawn O. Pearce schrieb:\n>>   git read-tree --reset HEAD\n> Sadly, this doesnt help. I still get the same error.\n> But, if I remove the corrupt index file, I get this:\n>\n> fatal: just how do you expect me to merge 0 trees?\n\nYea, so that sounds like \"git log\" doesn't work because HEAD isn't\npointing at a valid branch.\n\n> Does not look like a good sign :/\n> Are all my branches (branch==tree?) gone? (okay, werent that much)\n\nYes, a branch contains a series of trees.  The current tree of a\nbranch is the tree of the most recent commit on that branch.\n\nThey may be gone.\n\n-- \nShawn.\n"},{"id":"92283","messageId":"3ab397d0810031509i3e54252cp260a78de1d3faf8a@mail.gmail.com","threadId":"15778","inReplyTo":"48E696CB.6040405@gmx.de","subject":"Re: Broken index file - any hope?","fromName":"Jeff Whiteside","fromEmail":"jeff.m.whiteside@gmail.com","sentAt":"2008-10-03T22:09:37Z","receivedAt":"2008-10-03T22:09:37Z","isPatch":false,"sender":{"key":"jeff.m.whiteside@gmail.com","avatar":null},"body":"I don't know if you're new to git, but I used git for about a year\nbefore I knew what the index really was.\n\nRemember, the index file only stores changes you made to the\ncheckedout code AFTER the last commit, so all your commits are safely\nin the tree objects still.\n\nThe index is only a place to store changes you made with \"git add\",\nnot \"git commit\".\n\nI'm not sure how you refresh the index file but i would back\neverything up and try a \"git reset --hard\" or something.\n\n\n\nOn Fri, Oct 3, 2008 at 3:03 PM, Jonas Schneider <JonasSchneider@gmx.de> wrote:\n> Shawn O. Pearce schrieb:\n>>\n>>  git read-tree --reset HEAD\n>\n> Sadly, this doesnt help. I still get the same error.\n> But, if I remove the corrupt index file, I get this:\n>\n> fatal: just how do you expect me to merge 0 trees?\n>\n> Does not look like a good sign :/\n> Are all my branches (branch==tree?) gone? (okay, werent that much)\n>\n> Thanks anyway :)\n> -- Jonas\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":"92287","messageId":"alpine.LFD.2.00.0810032002240.3208@nehalem.linux-foundation.org","threadId":"15778","inReplyTo":"48E696CB.6040405@gmx.de","subject":"Re: Broken index file - any hope?","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2008-10-04T03:08:48Z","receivedAt":"2008-10-04T03:08:48Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 4 Oct 2008, Jonas Schneider wrote:\n\n> Shawn O. Pearce schrieb:\n> >   git read-tree --reset HEAD\n> Sadly, this doesnt help. I still get the same error.\n> But, if I remove the corrupt index file, I get this:\n> \n> fatal: just how do you expect me to merge 0 trees?\n\nSounds like you didn't recreate the whole .git directory - not only was \nyour index file corrupt, but apparently your .git/HEAD file is too.\n\nThe index is just a cache (apart from when you stage things into it \nand/or do merges), and the git read-tree should have recreated it for you. \nThe fact that it doesn't work implies that HEAD is corrupt or missing too.\n\nDoes \"git branch\" work for you? And what does .git/HEAD contain (normally \nit would just contain a single line saying \"ref: refs/heads/master\", but \nit obviously depends on which branch you were on, and it could just be a \ndetached head that just points directly to a SHA1).\n\n\t\tLinus\n"}]}