1

My Virtual machine crashed while trying to merge one local branch to another. After I restarted that machine I receive the following error when trying to do anything Git-Related:

git pull
fatal: not a git repository (or any of the parent directories): .git

There is a .git - subfolder which (on first sight) looks like just an ordinary git-folder containing .config .HEAD and so on

(Please don't mark this as duplicate for those questions where the op was just in the wrong directory. That is NOT the issue here)

Contents of the .git-Folder: enter image description here

(update) I just checked the source files I changed. They are completely destroyed containing only "NUL" - Values. So I guess there is no way I can retrieve any of my work done. So Checkout and start all over again it is, then.

Ole Albers
  • 8,715
  • 10
  • 73
  • 166

1 Answers1

0

I had a similar error after a system hard power off. The .git folder was no longer recognized and my local branches and commited files (but not pushed) seems to be gone. I recover my day work with the following steps :

  • Create a new folder and reinit a clean repo on the main branch
  • Go to your old .git folder and make a recursive copy in the sub tree for the hooks, info, logs, objects and ref folders to your freshly created clean .git folder. (I do not overwrite existing files)

And that's it. My local files and branches have been recovered. I think some git cache files and head meta were corrupted.

edit: Here is a more detail and cleaner way to do this : https://stackoverflow.com/a/27853585/4904074