1

I executed rm -rf on my working directory and even I interrupted the command immediately execution, I've lost several repositories that were not pushed to the remote (yet). One particular important repository that didn't have the latest commits(two months of work) seems to be partially damaged. Any idea if is it possible to save(partially)/repair it and how? The repository seems to occupy several MBs so there is still data in there.

git fsck reports about 1064 lines of errors such missing commit, missing blob, missing tree , dangling blob, broken link from tree <some sha> to tree <some sha>, refs/heads/master: invalid reflog, invalid sha1 pointer in cache-tree.

git-repair says Not in a git repository.

git status reports all the files deleted

Mihai
  • 438
  • 3
  • 13
  • I don't know if it helps... but you might take a look at the different objects that you are holding in the DB and see what they are and try to build the _latest_ revision from the separate pieces... not the simplest thing to pull off... but still better than losing 2 months of work, right?..... if you have the id of a given object, you can do this: `git cat-file -p the-id` and it will show you the content (and an object can be a revision, a tree, or a file.... among other less common types) – eftshift0 Dec 17 '20 at 17:57
  • 1
    If `git status` says that everything is deleted, try `git reset --hard` to see if you get content back.... _but_ make a backup of the whole thing before you start playing games with it. – eftshift0 Dec 17 '20 at 17:59
  • @eftshift0 thanks a lot for your help! it seems git reset --hard recovered some files...now I have to figure out their state. I've got a lot of errors `unable to read sha1 file of ` with a final `fatal: Could not reset index file to revision 'HEAD'` so I guess the reset stopped somewhere. – Mihai Dec 17 '20 at 18:05

0 Answers0