How can I list all commits that changed a specific file?
Is there a way to list all commits that changed a specific file?
--follow works for a particular file
git log --follow -- filename
Difference to other solutions given
Note that other solutions include
git log path (without the
--follow). That approach is handy if you want to track e.g. changes in a directory, but stumbles when files were renamed (thus use
Read more... Read less...
I have been looking at this closely and all these answers don‘t seem to really show me all the commits across all the branches.
Here is what I have come up with by messing around with the gitk edit view options. This shows me all the commits for a file regardless of branch, local, reflog, and remote.
gitk --all --first-parent --remotes --reflog --author-date-order -- filename
It also works with
git log --all --first-parent --remotes --reflog --author-date-order -- filename
Use the command below to get commits for a specific file:
git log -p filename
It should be as simple as
git log <somepath>; check the manpage (
Personally I like to use
git log --stat <path> so I can see the impact of each commit on the file.
Alternatively (since Git 1.8.4), it is also possible to just get all the commits which has changed a specific part of a file. You can get this by passing the starting line and the ending line number.
The result returned would be the list of commits that modified this particular part. The command goes like:
git log --pretty=short -u -L <upperLimit>,<lowerLimit>:<path_to_filename>
upperLimit is the
lowerLimit is the