Ugh. So I saw a bug logged today due to a missing piece of code. What?! That was there yesterday! Turns out I had deleted the file by accident and not realized it.
This article talks about How to find and restore deleted files with git, and wonderfully explains the first step: discovering the offending git commit.
git log --diff-filter=D --summary
This will give you a log of all commits which deleted a file. The --summary
will also show which files were deleted.
Given commit ID 123x7x
, run this to restore the file(s)
git checkout 123x7x~1 myFile
There's also a score of great answers on this StackOverflow question as well.