15

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?

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
endless
  • 3,316
  • 4
  • 26
  • 33
  • Open your files with a HEX-editor and look at what are the real endline chars. On Windows you should have CRLFs (no matter what numbers, it's 2 chars). Your code on Unix machine, pulled from git, may have LFs. That makes a difference. Git is "trained" to see that code as equal, SourceTree is not. – Nick Volynkin Jun 02 '15 at 19:48
  • Even if I run "git status" from the shell provided by SourceTree it shows those differences. Thing is how to force SourceTree to ignore those differences? – endless Jun 02 '15 at 20:25
  • I've got no idea how to configure SourceTree and if it is possible at all. But if you exchange code between developers with Git, you can setup Git to handle endlines. – Nick Volynkin Jun 02 '15 at 20:30
  • Just made a couple of suggestions on a similar question, hope that helps you. http://stackoverflow.com/questions/30603750/git-picking-up-whitespace-changes-it-shouldnt?noredirect=1#comment49278669_30603750 – Nick Volynkin Jun 02 '15 at 20:31
  • I have 2 machines with the exact same version of `git` and `sourcetreeapp` installed. One machine's source tree ignore the line ending difference. The other machine show entire file is changed because of the line ending difference. I don't know what causes it... – Zennichimaro Oct 26 '17 at 08:42

1 Answers1

16

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.

The screen shot

References:

The git command equivalent

Source Tree app settings

Zennichimaro
  • 5,236
  • 6
  • 54
  • 78