Broken index file - any hope?
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
Quoted 11 lines · Jonas Schneider
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.
Signature · 1 line
Shawn.
Quoted 1 line · Shawn O. Pearce
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
Quoted 6 lines · Jonas Schneider
Quoted 1 line · Shawn O. Pearce
git read-tree --reset HEADSadly, 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.
Quoted 2 lines
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.
Signature · 1 line
Shawn.
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.
Quoted 19 lines · Jonas Schneider
Quoted 2 lines · Shawn O. Pearce
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Jonas Schneider
Quoted 1 line · Shawn O. Pearce
git read-tree --reset HEADSadly, 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