{"thread":{"id":"26091","subject":"how to recover a repository","startedAt":"2010-12-17T04:28:40Z","lastAt":"2010-12-17T22:30:37Z","messageCount":5,"participants":["david@lang.hm","Jonathan Nieder","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"158263","messageId":"alpine.DEB.2.00.1012162024020.22269@asgard.lang.hm","threadId":"26091","inReplyTo":null,"subject":"how to recover a repository","fromName":"","fromEmail":"david@lang.hm","sentAt":"2010-12-17T04:28:40Z","receivedAt":"2010-12-17T04:28:40Z","isPatch":false,"sender":{"key":"david@lang.hm","avatar":null},"body":"I managed to do a 'rm *' in the .git directory (the usual sort of \nfat-fingering when cleaning up after another mistake)\n\nthe subdirectories are still there.\n\nthis is just a local repository, it won't kill me if I loose everything \n(as I still have the most recent working files), but I'd like to recover \nwhat I can.\n\nwhat can I do to get things back in a usable state?\n\nDavid Lang\n"},{"id":"158264","messageId":"20101217044530.GA8590@burratino","threadId":"26091","inReplyTo":"alpine.DEB.2.00.1012162024020.22269@asgard.lang.hm","subject":"Re: how to recover a repository","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-12-17T04:45:30Z","receivedAt":"2010-12-17T04:45:30Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi David,\n\ndavid@lang.hm wrote:\n\n> I managed to do a 'rm *' in the .git directory (the usual sort of\n> fat-fingering when cleaning up after another mistake)\n> \n> the subdirectories are still there.\n\nI'd suggest:\n\n 1. Make a backup!\n 2. From the worktree (i.e. parent to the .git directory),\n    run \"git init\".\n 3. git update-ref HEAD refs/heads/(branch you were on)\n 4. git reset;\t# (alas, the old index file is gone)\n 5. git diff; gitk --all\n\nSee gitrepository-layout(7) for details.\n"},{"id":"158289","messageId":"alpine.DEB.2.00.1012171218450.18272@asgard.lang.hm","threadId":"26091","inReplyTo":"20101217044530.GA8590@burratino","subject":"Re: how to recover a repository","fromName":"","fromEmail":"david@lang.hm","sentAt":"2010-12-17T20:20:56Z","receivedAt":"2010-12-17T20:20:56Z","isPatch":false,"sender":{"key":"david@lang.hm","avatar":null},"body":"On Thu, 16 Dec 2010, Jonathan Nieder wrote:\n\n> Hi David,\n>\n> david@lang.hm wrote:\n>\n>> I managed to do a 'rm *' in the .git directory (the usual sort of\n>> fat-fingering when cleaning up after another mistake)\n>>\n>> the subdirectories are still there.\n>\n> I'd suggest:\n>\n> 1. Make a backup!\n> 2. From the worktree (i.e. parent to the .git directory),\n>    run \"git init\".\n> 3. git update-ref HEAD refs/heads/(branch you were on)\n\nI was on the default branch but if I do 'git update-ref HEAD \nrefs/heads/master' I get an error 'not a valid SHA1'\n\n.git/refs/heads is empty\n\n.git/logs/HEAD looks like it shows all the commits in it properly\n\nDavid Lang\n\n> 4. git reset;\t# (alas, the old index file is gone)\n> 5. git diff; gitk --all\n>\n> See gitrepository-layout(7) for details.\n>\n"},{"id":"158295","messageId":"20101217212201.GC11511@sigill.intra.peff.net","threadId":"26091","inReplyTo":"alpine.DEB.2.00.1012171218450.18272@asgard.lang.hm","subject":"Re: how to recover a repository","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-12-17T21:22:02Z","receivedAt":"2010-12-17T21:22:02Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Dec 17, 2010 at 12:20:56PM -0800, david@lang.hm wrote:\n\n> >3. git update-ref HEAD refs/heads/(branch you were on)\n> \n> I was on the default branch but if I do 'git update-ref HEAD\n> refs/heads/master' I get an error 'not a valid SHA1'\n\nThat should be \"git symbolic-ref HEAD refs/heads/master\".\n\n-Peff\n"},{"id":"158298","messageId":"alpine.DEB.2.00.1012171430270.18272@asgard.lang.hm","threadId":"26091","inReplyTo":"20101217212201.GC11511@sigill.intra.peff.net","subject":"Re: how to recover a repository","fromName":"","fromEmail":"david@lang.hm","sentAt":"2010-12-17T22:30:37Z","receivedAt":"2010-12-17T22:30:37Z","isPatch":false,"sender":{"key":"david@lang.hm","avatar":null},"body":"thanks, that appears to have worked.\n\nDavid Lang\n\nOn Fri, 17 Dec 2010, Jeff King wrote:\n\n> Date: Fri, 17 Dec 2010 16:22:02 -0500\n> From: Jeff King <peff@peff.net>\n> To: david@lang.hm\n> Cc: Jonathan Nieder <jrnieder@gmail.com>, git@vger.kernel.org\n> Subject: Re: how to recover a repository\n> \n> On Fri, Dec 17, 2010 at 12:20:56PM -0800, david@lang.hm wrote:\n>\n>>> 3. git update-ref HEAD refs/heads/(branch you were on)\n>>\n>> I was on the default branch but if I do 'git update-ref HEAD\n>> refs/heads/master' I get an error 'not a valid SHA1'\n>\n> That should be \"git symbolic-ref HEAD refs/heads/master\".\n>\n> -Peff\n>\n"}]}