简体   繁体   中英

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. 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. Settings for those above attributes are exactly same.
    But SourceTree shows a bunch of differences in based on purely line endings.

What is the straightforward solution for this?
How come SourceTree has no settings in the UI around this?

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 !! I googled for hours, and finally got the answer after searching for SourceTree equivalent of the git command:

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

Source Tree app settings

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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