I was trying to initialize git on one of my projects. I added all my files / folders to the staging area using git add *
. I then committed a readme file, and then pushed it to remote repo. Then I committed 1 folder using git commit folder/*
and then did another push.
But after that, I did a git reset --hard
. Now all my files from the last few weeks are gone (I did not keep a backup of the project either), and I only have the readme file. Is there any way to recover the deleted files?
I tried getting the blob files using git fsck –lost-found
, and restored them using git show -p --format=raw $blob > $blob.txt
. But this gives me around 3000 blob files. How can I go through all these files to get the latest ones? Moreover, the filenames are random. Do I need to go through all 3000 files, match the appropriate files, and find out the latest version manually?