Broken index file - any hope?

6 messages, 4 authors, 2016-06-15 · open the first message on its own page

Broken index file - any hope?

From: Jonas Schneider <hidden>
Date: 2016-06-15 22:45:26

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

Re: Broken index file - any hope?

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:45:26

Jonas Schneider [off-list ref] 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.

Re: Broken index file - any hope?

From: Jonas Schneider <hidden>
Date: 2016-06-15 22:45:26

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

Re: Broken index file - any hope?

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:45:26

Jonas Schneider [off-list ref] wrote:
Shawn O. Pearce schrieb:
quoted
  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.

Re: Broken index file - any hope?

From: Jeff Whiteside <hidden>
Date: 2016-06-15 22:45:26

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 [off-list ref] wrote:
Shawn O. Pearce schrieb:
quoted
 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

Re: Broken index file - any hope?

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2016-06-15 22:45:26


On Sat, 4 Oct 2008, Jonas Schneider wrote:
Shawn O. Pearce schrieb:
quoted
  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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help