I'm using SourceTree for easy code reviewing before committing. Within SourceTree I often stage and commit only part of the lines which I changed in a document.
A couple days ago I received a piece of code from a programmer working on Windows, which caused some trouble with line endings. If I remember correctly, I then set core.autocrlf
to true
, which fixed the issues with the windows file.
Since that moment however, I'm having major issues in another repo I'm working on. If I want to stage only part of a file in SourceTree I now get a massive error saying git apply' failed with code 1: [/a/long/path/here] trailing whitespace in SourceTree
. So I figured I needed to set core.autocrlf
back to what it was, which I "assumed" to be ("mother of all.. etc") false
(I never messed with core.autocrlf
before). So I set it to false
which suddenly makes all files on which I change only one letter to be marked as having changed ALL lines in the file, which is obviously a major hassle during code review.
So I searched around and I found some examples of solutions here on SO, but that all uses adding extra parameters to git add
and doing all kinds of weird stuff. Next to the fact that I don't think I can insert custom commands in the GUI of SourceTree I mostly wondered; How did it get so messy? And most importantly can't I just go back to how it was (whatever that was) instead of having to issue extra command everytime that I want to stage and commit?
Please note; I'm not afraid of the command line, I work in it pretty much the whole day. But I just like doing code reviews in a GUI such as SourceTree.
Any tip which helps me get things back to normal would greatly help me out!
Set "Ignore whitespace". See screenshot:
There is a discussion on Atlassian Community about this problem. The fix is to switch setting Show Whitespace to Ignore Whitespace.
In your ~/.gitconfig, try adding the following section:
[apply]
whitespace = nowarn
The full details of what this does are covered at https://git-scm.com/docs/git-apply
The options for apply.whitespace are (from the git-scm page):
Seems like the default for SourceTree under OS X is "error", at least with git 2.6.4. Or it may be interacting with our default of core.autocrlf = true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With