Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

git log --follow <myfile> shows the git log for one file.

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?

like image 589
mik01aj Avatar asked Aug 05 '15 09:08

mik01aj


People also ask

Why is git diff not showing anything?

Why do you get no git diff output before adding? Git does not treat files in the filesystem as automatically included in the version control system. You have to add things explicitly into the Git repository (as you are doing by adding the current directory with git add . ).

How do I continue git diff?

Type /^diff and press Enter to skip to the next file. Save this answer.

What does ++ mean in git diff?

When viewing a combined diff, if the two files you're comparing have a line that's different from what they were merged into, you will see the ++ to represent: one line that was added does not appear in either file1 or file2.

What is the difference between git log and git log?

log differences. The biggest difference between Git reflog vs. log is that the log is a public accounting of the repository's commit history while the reflog is a private, workspace-specific accounting of the repo's local commits. The Git log is part of the Git repository and is replicated after a push, fetch or pull.


1 Answers

You can get it like this:

git diff <file_path_relative_to_project_root>

Edited:

Explanation: 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.

like image 183
Sahil Avatar answered Sep 24 '22 16:09

Sahil