mauris mauris - 1 month ago 17
Git Question

git log shows diff despite --no-patch

I'm using Git v2.10.2 (finally an update) on macOS Sierra. I noticed in the

git log
command, whenever I use the
-L
argument to look at specific lines of code of a file,
git log
prints out the diff output even when
--no-patch
is specified clearly. Without the
-L
, it works as it should behaves.

Is there something I'm missing with the
-L
parameter? Thanks!

Sample command:

git log --oneline --no-patch -L 1,3:package.json

Answer

--no-patch doesn't make sense with -L and therefore it is ignored. By providing the -L option, you select a range of lines in the specified revision of a file and tell git to show the history of that fragment, which cannot be done without showing diffs.