Find commit in which file was deleted

Asked

Viewed 264 times

2

I have a project in Git. I need to retrieve a file that was deleted several months ago.

If it were something that was now in the repository it would be trivial to find it, see its history and changes. But as it is something that has been removed, I am having difficulty getting the latest version of the file prior to its deletion.

For lack of a better alternative, I’m thinking of doing a binary search on commits... But I will be very grateful (and I believe many others will be) if they indicate a more efficient way to find the commit in which something has been removed.

1 answer

2


If you know the path of the file that was deleted, use:

git log --all -- <arquivo>

Otherwise, use:

git log --diff-filter=D --summary | grep delete

Reference: here.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.