The git log
command lists all of the commits in the repository’s history.
git log [<options>]
The options relevant to this Answer are as follows:
--full-history
: This flag tells Git not to hide out (or prune) any history associated with the file. In other words, history simplification will not be done.We use the git log
command with the --full-history
option to find out when a file was deleted.
The command is as follows:
git log --full-history -- file_name
The command above lists all the commits (including merge commits) that touched file_name
. The last (top) commit is the one that deleted the file.
For example, consider the file test.txt
. Let’s insert this file name in the above command:
git log --full-history -- test.txt
This will give the following output.
commit <commit-id>
Author: Arthur Chang
Date: Sat Jan 15 15:15:15 2020 +0012
Deleted test.txt
commit <commit-id>
Author: Arthur Chang
Date: Sat Jan 18 17:18:19 2020 +0012
Added test.txt
Here, the first (that is, the top) commit date is the date when the file test.txt
was deleted.
Free Resources