Why can't I use git log –follow with –full-diff?
I’d like to see this log with all the changes (diffs) in this file. I try:
git log --full-diff --follow <myfile>
But this fails with:
fatal: --follow requires exactly one pathspec
Why? How can I get the diff I wanted?
Or maybe, is it a bug in git?
2 Solutions collect form web for “Why can't I use git log –follow with –full-diff?”
You can get it like this:
git diff <file_path_relative_to_project_root>
Took a while to understand this. Whenever
git log -p <file> is used it shows the commits where ever the file was touched and diffs for the same file alone. That means if you want to follow the complete history of a file you can add –follow option and get to see the complete history.
But when you enter this command:
git log --full-diff -p file , it shows you all the commits where ever this file was touched plus now it not only shows diff for the specified file but also shows the diff’s for all the files that were touched in the commit. That means its giving you result for multiple files.
If you try this command:
git log help
You’ll see that –follow option can only be used only for a single file so
you can have a command like this:
git log --follow -p file since it shows results for only single file.
But it cannot be used with the following command:
git log --full-diff --follow -p file as it shows results for multiple files and this query would result in an error.
TL;DR version of Sahil’s answer:
In git log,
--full-diff doesn’t work with
--follow, because “full” means “show all changed files”, and
--follow works only with one file.
git log --follow -p <file>.