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

时间:2015-06-02 18:06:25

标签: git atlassian-sourcetree line-endings

有很多帖子,但分辨率不明确或不适合我。问题似乎众所周知..

  1. 我在unix中检查了我的项目,git状态显示没有差异。 设置在这里:

    bash-3.2$ git config core.autocrlf
    false
    bash-3.2$ git config core.whitespace
    cr-at-eol
    
  2. 但我也喜欢使用SourceTree(通过NFS挂载指向相同的Unix代码库)以获得一些便利。 上述属性的设置完全相同 但SourceTree基于纯粹的行结尾显示了一系列差异。

  3.   

    对此有什么简单的解决方案?
       为什么SourceTree在UI中没有设置?

1 个答案:

答案 0 :(得分:8)

SourceTree应用的diff-ui部分附近有gear icon显示您的文件差异,您可以点击它并将其设置为show whitespaceignore whitespace !!我用Google搜索了几个小时,最后在搜索了相当于git命令的SourceTree之后得到了答案:

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.

The screen shot

参考文献:

The git command equivalent

Source Tree app settings