Git problems with line endings differences between linux and windows
Maybe someone else working on the project introduced bad line endings. two things 2 do:
- fix bad line endings already committed.
- align the team about the line endings policy.
See: Dealing with line endings.
Historical reason behind different line ending at different platforms
DOS inherited CR-LF line endings (what you're calling \r\n, just making the ascii characters explicit) from CP/M. CP/M inherited it from the various DEC operating systems which influenced CP/M designer Gary Kildall.
CR-LF was used so that the teletype machines would return the print head to the left margin (CR = carriage return), and then move to the next line (LF = line feed).
The Unix guys handled that in the device driver, and when necessary translated LF to CR-LF on output to devices that needed it.
And as you guessed, Mac OS X now uses LF.
Difference between CR LF, LF and CR line break types?
It's really just about which bytes are stored in a file. CR
is a bytecode for carriage return (from the days of typewriters) and LF
similarly, for line feed. It just refers to the bytes that are placed as end-of-line markers.
Way more information, as always, on wikipedia.
Git - Windows AND linux line-endings
On Windows:
$ git config --global core.autocrlf true
On Linux:
$ git config --global core.autocrlf input
Read more about Dealing with line endings
Git CRLF and LF line ending on windows/linux
Don't forget to add a .gitattributes
rule for that file, in order to force lf for that file
a_file text=auto eol=lf
But regarding your send-email issue, see "git am/format-patch
: control format of line endings", try and use git send-email --transfer-encoding=base64
, to make sure everything is preserved (including eol)
How can I ignore line endings when comparing files?
Use the --strip-trailing-cr
option:
diff --strip-trailing-cr file1 file2
The option causes diff
to strip the trailing carriage return character before comparing the files.
Related Topics
Java.Lang.Classnotfoundexception: Didn't Find Class on Path: Dexpathlist
Download a File With Android, and Showing the Progress in a Progressdialog
Firebaselistadapter Not Pushing Individual Items For Chat App - Firebase-Ui 3.1
Json Array Iteration in Android/Java
How to Parse Invalid (Bad/Not Well-Formed) Xml
How to Avoid Arrayindexoutofboundsexception or Indexoutofboundsexception
Setting the Default Java Character Encoding
How to Filter a Java Collection (Based on Predicate)
How to Count the Number of Occurrences of a Char in a String
How to Create a Memory Leak in Java
How to Simulate the C++ 'Friend' Concept in Java
Android 6.0 Multiple Permissions
Android Activity Classnotfoundexception - Tried Everything
Avoiding Nullpointerexception in Java
How to Read a Single Char from the Console in Java (As the User Types It)