git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* how to recover a repository
@ 2010-12-17  4:28 david
  2010-12-17  4:45 ` Jonathan Nieder
  0 siblings, 1 reply; 5+ messages in thread
From: david @ 2010-12-17  4:28 UTC (permalink / raw)
  To: git

I managed to do a 'rm *' in the .git directory (the usual sort of 
fat-fingering when cleaning up after another mistake)

the subdirectories are still there.

this is just a local repository, it won't kill me if I loose everything 
(as I still have the most recent working files), but I'd like to recover 
what I can.

what can I do to get things back in a usable state?

David Lang

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: how to recover a repository
  2010-12-17  4:28 how to recover a repository david
@ 2010-12-17  4:45 ` Jonathan Nieder
  2010-12-17 20:20   ` david
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Nieder @ 2010-12-17  4:45 UTC (permalink / raw)
  To: david; +Cc: git

Hi David,

david@lang.hm wrote:

> I managed to do a 'rm *' in the .git directory (the usual sort of
> fat-fingering when cleaning up after another mistake)
> 
> the subdirectories are still there.

I'd suggest:

 1. Make a backup!
 2. From the worktree (i.e. parent to the .git directory),
    run "git init".
 3. git update-ref HEAD refs/heads/(branch you were on)
 4. git reset;	# (alas, the old index file is gone)
 5. git diff; gitk --all

See gitrepository-layout(7) for details.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: how to recover a repository
  2010-12-17  4:45 ` Jonathan Nieder
@ 2010-12-17 20:20   ` david
  2010-12-17 21:22     ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: david @ 2010-12-17 20:20 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: git

On Thu, 16 Dec 2010, Jonathan Nieder wrote:

> Hi David,
>
> david@lang.hm wrote:
>
>> I managed to do a 'rm *' in the .git directory (the usual sort of
>> fat-fingering when cleaning up after another mistake)
>>
>> the subdirectories are still there.
>
> I'd suggest:
>
> 1. Make a backup!
> 2. From the worktree (i.e. parent to the .git directory),
>    run "git init".
> 3. git update-ref HEAD refs/heads/(branch you were on)

I was on the default branch but if I do 'git update-ref HEAD 
refs/heads/master' I get an error 'not a valid SHA1'

.git/refs/heads is empty

.git/logs/HEAD looks like it shows all the commits in it properly

David Lang

> 4. git reset;	# (alas, the old index file is gone)
> 5. git diff; gitk --all
>
> See gitrepository-layout(7) for details.
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: how to recover a repository
  2010-12-17 20:20   ` david
@ 2010-12-17 21:22     ` Jeff King
  2010-12-17 22:30       ` david
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff King @ 2010-12-17 21:22 UTC (permalink / raw)
  To: david; +Cc: Jonathan Nieder, git

On Fri, Dec 17, 2010 at 12:20:56PM -0800, david@lang.hm wrote:

> >3. git update-ref HEAD refs/heads/(branch you were on)
> 
> I was on the default branch but if I do 'git update-ref HEAD
> refs/heads/master' I get an error 'not a valid SHA1'

That should be "git symbolic-ref HEAD refs/heads/master".

-Peff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: how to recover a repository
  2010-12-17 21:22     ` Jeff King
@ 2010-12-17 22:30       ` david
  0 siblings, 0 replies; 5+ messages in thread
From: david @ 2010-12-17 22:30 UTC (permalink / raw)
  To: Jeff King; +Cc: Jonathan Nieder, git

thanks, that appears to have worked.

David Lang

On Fri, 17 Dec 2010, Jeff King wrote:

> Date: Fri, 17 Dec 2010 16:22:02 -0500
> From: Jeff King <peff@peff.net>
> To: david@lang.hm
> Cc: Jonathan Nieder <jrnieder@gmail.com>, git@vger.kernel.org
> Subject: Re: how to recover a repository
> 
> On Fri, Dec 17, 2010 at 12:20:56PM -0800, david@lang.hm wrote:
>
>>> 3. git update-ref HEAD refs/heads/(branch you were on)
>>
>> I was on the default branch but if I do 'git update-ref HEAD
>> refs/heads/master' I get an error 'not a valid SHA1'
>
> That should be "git symbolic-ref HEAD refs/heads/master".
>
> -Peff
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-12-17 22:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-17  4:28 how to recover a repository david
2010-12-17  4:45 ` Jonathan Nieder
2010-12-17 20:20   ` david
2010-12-17 21:22     ` Jeff King
2010-12-17 22:30       ` david

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).