git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Broken index file - any hope?
@ 2008-10-03 21:51 Jonas Schneider
  2008-10-03 21:53 ` Shawn O. Pearce
  0 siblings, 1 reply; 6+ messages in thread
From: Jonas Schneider @ 2008-10-03 21:51 UTC (permalink / raw)
  To: git

Hey guys,

I come from the Ruby on Rails world, where Git is now spreading like ... 
duh, something fast.
Today I sadly lost my complete .git directory, only the working copy was 
left behind.
I reconstructed the directory, but the index file seems to be corrupt, 
every command just tells me about a bad signature.
I hope the rest of the repository is intanct. If it is, is there any 
chance to restore/rebuild that index file from the rest?
I don't have an idea of the internals of git, but I know the objects are 
stored in different files, and maybe on top of that
I could rebuild the index file.

Any hope?
Thanks,
--Jonas Schneider

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

* Re: Broken index file - any hope?
  2008-10-03 21:51 Broken index file - any hope? Jonas Schneider
@ 2008-10-03 21:53 ` Shawn O. Pearce
  2008-10-03 22:03   ` Jonas Schneider
  0 siblings, 1 reply; 6+ messages in thread
From: Shawn O. Pearce @ 2008-10-03 21:53 UTC (permalink / raw)
  To: Jonas Schneider; +Cc: git

Jonas Schneider <JonasSchneider@gmx.de> wrote:
> I come from the Ruby on Rails world, where Git is now spreading like ...  
> duh, something fast.
> Today I sadly lost my complete .git directory, only the working copy was  
> left behind.
> I reconstructed the directory, but the index file seems to be corrupt,  
> every command just tells me about a bad signature.
> I hope the rest of the repository is intanct. If it is, is there any  
> chance to restore/rebuild that index file from the rest?
> I don't have an idea of the internals of git, but I know the objects are  
> stored in different files, and maybe on top of that
> I could rebuild the index file.

Give this a shot:

  git read-tree --reset HEAD
  git status

at worst you lose staged changes.  At best you recover the index
file.

-- 
Shawn.

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

* Re: Broken index file - any hope?
  2008-10-03 21:53 ` Shawn O. Pearce
@ 2008-10-03 22:03   ` Jonas Schneider
  2008-10-03 22:07     ` Shawn O. Pearce
                       ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jonas Schneider @ 2008-10-03 22:03 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git

Shawn O. Pearce schrieb:
>   git read-tree --reset HEAD
Sadly, this doesnt help. I still get the same error.
But, if I remove the corrupt index file, I get this:

fatal: just how do you expect me to merge 0 trees?

Does not look like a good sign :/
Are all my branches (branch==tree?) gone? (okay, werent that much)

Thanks anyway :)
-- Jonas

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

* Re: Broken index file - any hope?
  2008-10-03 22:03   ` Jonas Schneider
@ 2008-10-03 22:07     ` Shawn O. Pearce
  2008-10-03 22:09     ` Jeff Whiteside
  2008-10-04  3:08     ` Linus Torvalds
  2 siblings, 0 replies; 6+ messages in thread
From: Shawn O. Pearce @ 2008-10-03 22:07 UTC (permalink / raw)
  To: Jonas Schneider; +Cc: git

Jonas Schneider <JonasSchneider@gmx.de> wrote:
> Shawn O. Pearce schrieb:
>>   git read-tree --reset HEAD
> Sadly, this doesnt help. I still get the same error.
> But, if I remove the corrupt index file, I get this:
>
> fatal: just how do you expect me to merge 0 trees?

Yea, so that sounds like "git log" doesn't work because HEAD isn't
pointing at a valid branch.

> Does not look like a good sign :/
> Are all my branches (branch==tree?) gone? (okay, werent that much)

Yes, a branch contains a series of trees.  The current tree of a
branch is the tree of the most recent commit on that branch.

They may be gone.

-- 
Shawn.

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

* Re: Broken index file - any hope?
  2008-10-03 22:03   ` Jonas Schneider
  2008-10-03 22:07     ` Shawn O. Pearce
@ 2008-10-03 22:09     ` Jeff Whiteside
  2008-10-04  3:08     ` Linus Torvalds
  2 siblings, 0 replies; 6+ messages in thread
From: Jeff Whiteside @ 2008-10-03 22:09 UTC (permalink / raw)
  To: Jonas Schneider; +Cc: Shawn O. Pearce, git

I don't know if you're new to git, but I used git for about a year
before I knew what the index really was.

Remember, the index file only stores changes you made to the
checkedout code AFTER the last commit, so all your commits are safely
in the tree objects still.

The index is only a place to store changes you made with "git add",
not "git commit".

I'm not sure how you refresh the index file but i would back
everything up and try a "git reset --hard" or something.



On Fri, Oct 3, 2008 at 3:03 PM, Jonas Schneider <JonasSchneider@gmx.de> wrote:
> Shawn O. Pearce schrieb:
>>
>>  git read-tree --reset HEAD
>
> Sadly, this doesnt help. I still get the same error.
> But, if I remove the corrupt index file, I get this:
>
> fatal: just how do you expect me to merge 0 trees?
>
> Does not look like a good sign :/
> Are all my branches (branch==tree?) gone? (okay, werent that much)
>
> Thanks anyway :)
> -- Jonas
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: Broken index file - any hope?
  2008-10-03 22:03   ` Jonas Schneider
  2008-10-03 22:07     ` Shawn O. Pearce
  2008-10-03 22:09     ` Jeff Whiteside
@ 2008-10-04  3:08     ` Linus Torvalds
  2 siblings, 0 replies; 6+ messages in thread
From: Linus Torvalds @ 2008-10-04  3:08 UTC (permalink / raw)
  To: Jonas Schneider; +Cc: Shawn O. Pearce, git



On Sat, 4 Oct 2008, Jonas Schneider wrote:

> Shawn O. Pearce schrieb:
> >   git read-tree --reset HEAD
> Sadly, this doesnt help. I still get the same error.
> But, if I remove the corrupt index file, I get this:
> 
> fatal: just how do you expect me to merge 0 trees?

Sounds like you didn't recreate the whole .git directory - not only was 
your index file corrupt, but apparently your .git/HEAD file is too.

The index is just a cache (apart from when you stage things into it 
and/or do merges), and the git read-tree should have recreated it for you. 
The fact that it doesn't work implies that HEAD is corrupt or missing too.

Does "git branch" work for you? And what does .git/HEAD contain (normally 
it would just contain a single line saying "ref: refs/heads/master", but 
it obviously depends on which branch you were on, and it could just be a 
detached head that just points directly to a SHA1).

		Linus

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

end of thread, other threads:[~2008-10-04  3:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-03 21:51 Broken index file - any hope? Jonas Schneider
2008-10-03 21:53 ` Shawn O. Pearce
2008-10-03 22:03   ` Jonas Schneider
2008-10-03 22:07     ` Shawn O. Pearce
2008-10-03 22:09     ` Jeff Whiteside
2008-10-04  3:08     ` Linus Torvalds

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