How To Recover a Deleted File From Your Git Repository

First if you’re not sure of the name of the deleted file check through your Git log ..

1
git log --diff-filter=D --summary

Find the last commit that affected the given file

1
git rev-list -n 1 HEAD -- ./path/to/file/

.. I’ll refer to that as REVISON_NUMBER

Now we can checkout the previous revision

1
git checkout REVISON_NUMBER^ -- ./path/to/file/