Do Line Endings Differ Between Windows and Linux

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:

  1. fix bad line endings already committed.
  2. 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



Leave a reply



Submit