Git - The Change History of a Specific File
Let say you have a file that is tracked by Git and has a commit history.
Some day you will want to look back to see what has happened with this file.
The most basic and powerful tool to do this is the git log command.
Using the different options, it can show the commit history of a file, history of diffs and up to the history of renames.
Show the Change History of a File
Use one of the below commands to get the change history of an individual file using Git.
History of Commits Only
Show only commits of an individual file:
$ git log -- [filename]
History of Commits with Diffs
Show commits with diffs for each change:
$ git log -p -- [filename]
History of Commits with Diffs including Renames
Show the entire history of a file (including history beyond renames).
$ git log --follow -p -- [filename]