I have a MacBook and am running Windows in a Parallels VM. My development is primarily in Visual Studio, but I like to use Git with the Mac shell (just like it better than what is available for Windows).
When I do a git diff to determine what has changed between commits I am getting the proverbial line ending "changes" that make git think much more has changed than actually has.
I know this is an age old problem, and I have done a lot of research with varying suggestions from a lot of people, but I am not able to solve this issue. The most promising information was found in this SO Post but it didn't solve my issue.
Here are some relevant lines from my .gitconfig...
[core]
autocrlf = false
safecrlf = false
Also, I have a .gitattributes in the root of my repo that only contains...
* text eol=crlf
What can I do to make Git stop thinking line ending changes are real changes when performing a diff? Again, I am using a Mac shell to look at Windows files, so this might be part of my issue.
Thanks!
Line Breaks in Windows, UNIX & Macintosh Text Files Windows, and DOS before it, uses a pair of CR and LF characters to terminate lines. UNIX (Including Linux and FreeBSD) uses an LF character only. OS X also uses a single LF character, but the classic Mac operating system used a single CR character for line breaks.
MAC OS X seems to be using unix-like line endings (LF) instead of the old mac line endings (CR). However if you use VIM (the one that comes preinstalled, at least in my macbook), you might get a surprise and get your files with dos-like line endings (CRLF).
The Multics operating system began development in 1964 and used LF alone as its newline. Multics used a device driver to translate this character to whatever sequence a printer needed (including extra padding characters), and the single byte was more convenient for programming.
The Mac, by default, uses a single carriage return ( <CR> ), represented as \r . Unix, on the other hand, uses a single linefeed ( <LF> ), \n . Windows goes one step further and uses both, creating a ( <CRLF> ) combination, \r\n .
I alias gdiff
to:
git diff -w origin/`git branch | sed --quiet "s/* \(.*\)/\1/p"`
but you can just do:
git diff -w
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