0

I have a folder which is my git local repository, and there are two folders in it the web folder and backend folder.

I ran this command git rm -r -f web and then all my files inside the web folder were gone, and now I can't find it, I tried to look for it in the trash, but the files aren't there, is there a way I can go back in time and restore all the files?

Nitin Bisht
  • 5,053
  • 4
  • 14
  • 26
Eduardo
  • 407
  • 1
  • 4
  • 12

1 Answers1

0

This command will help you to retrieve your previous commit,

git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file"
  • When I try to run this command, it says 'fatal: empty string is not a valid pathspec. please use . instead if you meant to match all paths fatal: invalid reference: ^' – Eduardo Feb 22 '20 at 03:11
  • There has been a similar question, check it out, [link](https://stackoverflow.com/questions/953481/find-and-restore-a-deleted-file-in-a-git-repository?rq=1) – khavinshankar Feb 22 '20 at 03:20