Post

GIT: When files are deleted in some commit in the past

Harianto van Insulinde
GIT: When files are deleted in some commit in the past

Find the last commit that affected the given path. As the file isn't in the HEAD commit, this commit must have deleted it.

bash
git rev-list -n 1 HEAD -- <file_path>

Then checkout the version at the commit before, using the caret (^) symbol:

bash
git checkout <deleting_commit>^ -- <file_path>

Restore the full working tree from a distant commit

bash
git reset --hard <revision>