Why can't I use git log --follow with -full-diff?

git log --follow <myfile> shows git log for a single file.

I would like to see this log with all the changes (differences) in this file. I'm trying to:

 git log --full-diff --follow <myfile> 

But this fails:

 fatal: --follow requires exactly one pathspec 

Why? How can I get the diff I need?

Or maybe this is a bug in git?

+5
source share
2 answers

You can do it as follows:

 git diff <file_path_relative_to_project_root> 

Edited by:

Explanation : It took a while to figure this out. Whenever git log -p <file> , it shows the commits where the file has ever been affected, and the differences for the same file. This means that if you want to follow the full history of the file, you can add the - follow option and see the full history.

But when you enter this command: git log --full-diff -p file , it shows you all the commits where this file has ever been affected, plus now it not only shows diff for the specified file, but also shows diff for everyone files that were affected by commit. This means that it gives you the result for multiple files.

If you try this command: git log help you will see that the - follow option can only be used for one file, so you can have this command: git log --follow -p file , since it shows the results for only one file.

But it cannot be used with the following command: git log --full-diff --follow -p file , since it shows results for multiple files, and this query will result in an error.

+3
source

TL DR version of Sahil's answer:

In git log, --full-diff does not work with --follow , because "full" means "show all modified files" , and --follow only works with one file.

Solution: use git log --follow -p <file> .

+3
source

All Articles