git diff, how can I ignore changes which start with
diff command, I would use something like:
diff <(grep -v '^#' file1) <(grep -v '^#' file2)
But none of the suggested solutions below work!
Is there really no way to see
git diff with comments omitted?
I tries this in my
[pager] cdiff = diff-highlight [alias] cdiff = "diff -w --ignore-blank-lines -I'^#'"
When I do
git cdiff, I get this error:
error: invalid option: -I^#
this is so frustrating. The syntax
git diff -G'^[^#]' does not work reliably. Example:
$ cat 1.txt aaa bbb ccc ddd eee fff ggg hhh iii jjj
initialize new git repo:
$ git init && git add . && git commit -m "initial commit" -a
add only comment on top of file:
$ cat 1.txt # comment aaa bbb ccc ddd eee fff ggg hhh iii jjj
so far, it works as expected.
git diff -G'^[^#]' does not show the comment as change. But if I add a real change at the last line, and then do
git diff -G'^[^#]' again, it then shows the added last line (as it should), but also the first line comment which it did not show before.
So basically, as soon as I add any non-comment change, git shows everything, even comments.