Git commit显示总文件替换而不是逐行更改

Ger*_*int 3 git github pull-request

每当一位同事发给我一个拉取请求并且我在GitHub上查看它时,提交中的一些文件显示为全新内容,例如1200行删除和1220行添加,其中他实际上只添加了20行.

文件没有重新格式化,眼​​睛看起来几乎没有变化,但Git显示100%粉红色,然后是100%绿色.

非常感激地接受任何可能导致这种情况的想法.

AD7*_*six 5

一个真实的例子会有所帮助,但很可能......

新线

线路结尾不同.Github有一个有用的页面,解释了如何配置git,以便透明地处理这些差异:

git config --global core.autocrlf input
# Set this setting on OSX or Linux

git config --global core.autocrlf true
# Set this setting on Windows
Run Code Online (Sandbox Code Playgroud)

您还可以通过修改编辑器设置来解决问题.

请仅查看非空白更改

git diff可用于查看忽略空格的实际差异.它有各种模式,例如:

git diff --ignore-space-change someotherbranch
Run Code Online (Sandbox Code Playgroud)

将输出差异,忽略缩进和行结尾的差异.