At first, I was using the following command:
Method 1: using git log file path filter
We can use the below command to search git log for commits that touches an specific file
git log --all -- deleted_file.example --oneline
Obviously, instead of deleted_file.example
we will have to write the exact name/path of the file that we are looking for. So, if we are searching for main.py
it will be git log --all -- main.py
This will list all the commits that touched the file but, there is a better alternative in newer version of gits:
Method 2: using diff-filter
The below command filters commits that deleted file using diff-filter from git log
git log --diff-filter=D -- deleted_file.example
It takes advantage of the flag diff-filter. The cool thing about diff-filter is we can also use it to find the commit that first added the file! example:
git log --diff-filter=A -- file.example