How to list all commits that changed a specific file?
Solution 1:
The --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 --follow filename
).
Solution 2:
git log path
should do what you want. From the git log
man page:
[--] <path>…
Show only commits that affect any of the specified paths. To prevent confusion with
options and branch names, paths may need to be prefixed with "-- " to separate them
from options or refnames.
Solution 3:
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
:
git log --all --first-parent --remotes --reflog --author-date-order -- filename