简体   繁体   English

强制SourceTree忽略git文件中的行结尾

[英]Force SourceTree ignore line endings in git files

There are so many posts but still the resolution is not clear or isn't working for me. 有这么多帖子,但仍然没有明确或不适合我的决议。 Problem seems to be well known.. 问题似乎众所周知..

  1. I checked out my project in unix and git status shows no differences. 我在unix中检查了我的项目,git状态显示没有差异。 Settings here: 设置在这里:

     bash-3.2$ git config core.autocrlf false bash-3.2$ git config core.whitespace cr-at-eol 
  2. But I also like to use SourceTree (pointing to the same Unix code base through NFS mount) for some conveniences. 但我也喜欢使用SourceTree(通过NFS挂载指向相同的Unix代码库)以获得一些便利。 Settings for those above attributes are exactly same. 上述属性的设置完全相同。
    But SourceTree shows a bunch of differences in based on purely line endings. 但SourceTree基于纯粹的行结尾显示了一系列差异。

What is the straightforward solution for this? 什么是直截了当的解决方案?
How come SourceTree has no settings in the UI around this? 为什么SourceTree在这个UI中没有设置?

There is a gear icon near the diff-ui section of the SourceTree app that show your file difference, you can click on it and set it to show whitespace or ignore whitespace !! SourceTree应用程序的diff-ui部分附近有一个gear icon ,显示您的文件差异,您可以单击它并将其设置为show whitespaceignore whitespace I googled for hours, and finally got the answer after searching for SourceTree equivalent of the git command: 我用Google搜索了几个小时,最后在搜索SourceTree等效的git命令后得到了答案:

Git version <= 1.8.3.4:
git diff --ignore-space-at-eol -b -w [commit] ...

Git version >= 1.8.4:
git diff --ignore-space-at-eol -b -w --ignore-blank-lines [commit] ...

See the options definition below:

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

[git version 1.8.4+]--ignore-blank-lines 
Ignore changes whose lines are all blank.

屏幕截图

References: 参考文献:

The git command equivalent git命令等价

Source Tree app settings 源树应用程序设置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM