Git: Recover a deleted file

Hi,

To get a deleted file from git (whatever the reason could be), there the command:


file="filepath"
git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file"

Source: https://stackoverflow.com/questions/953481/find-and-restore-a-deleted-file-in-a-git-repository

About Saïd

Software developer.
This entry was posted in General. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.