git-diff的技巧

git diff 加 -R 参数显示回车符(^M)

git diff 时忽略空格

有时格式化过commit,会使得全文看起来都改变了,其实只是空格、tab的变化。

使用diff的ignore options可以忽略这些。

1
2
3
4
5
6
7
8
9
10
11
12
git diff

       --ignore-space-at-eol
           Ignore changes in whitespace at EOL.

       -b, --ignore-space-change
           Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of
           one or more whitespace characters to be equivalent.

       -w, --ignore-all-space
           Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other
           line has none.