How do I find and restore a deleted file in a Git repository?
Find the last commit that affected the given path. As the file isn’t in the HEAD commit, that previous commit must have deleted it. git rev-list -n 1 HEAD — <file_path> Then checkout the version at the commit before, using the caret (^) symbol: git checkout <deleting_commit>^ — <file_path> Or in one command, if $file … Read more