aleksandrhovhannisyan.com icon indicating copy to clipboard operation
aleksandrhovhannisyan.com copied to clipboard

CRLF vs. LF: Normalizing Line Endings in Git

Open AleksandrHovhannisyan opened this issue 3 years ago • 25 comments

AleksandrHovhannisyan avatar May 11 '21 11:05 AleksandrHovhannisyan

Very useful. Thank you.

ekortright avatar Jun 15 '21 13:06 ekortright

Cool about the history. I still used teletypewriters with a dial up phone modem in a computer lab.

image

chriswayg avatar Jun 22 '21 08:06 chriswayg

For an engineer, this rivet is very important, without it, you can't build a building

SKSSSX avatar Aug 12 '21 09:08 SKSSSX

Thank You so much, I like articles like this where there is details like the historical ones.

DhrumilDave5 avatar Sep 30 '21 11:09 DhrumilDave5

You just saved me a lot of time, thank you!

gregorybleiker avatar Nov 22 '21 18:11 gregorybleiker

Thanks for the great article. In * text=auto eol=lf doesn't the text=auto get ignored? Because setting eol=lf treats all files as text. I was getting confused on this and asked this question here as well.

ahmafi avatar Jan 09 '22 06:01 ahmafi

@ahmafi Oh, interesting—I think you may be right! It looks like text=auto tells Git to use its file-type detection algorithm to apply LF to text files, so eol=lf is redundant. Let me play around with this a bit more, and then I'll update the post to clarify it a bit better.

AleksandrHovhannisyan avatar Jan 09 '22 16:01 AleksandrHovhannisyan

Nice article, easy to understand and apply, and a bit too long :(

djnotes avatar Feb 07 '22 10:02 djnotes

Nice article, very interesting and useful. Thank you!

germanfrelo avatar Mar 05 '22 16:03 germanfrelo

Very useful. Thanks a lot!

Jeff-Hugh avatar Apr 12 '22 03:04 Jeff-Hugh

You made my day, thank you! Finally a solution for this. Красава!

denislutz avatar Apr 18 '22 09:04 denislutz

Thanks for writing this article -- I especially appreciated the sections about verifying line endings after the change and then updating the files in your working tree. That's when everything finally clicked for me. :-)

KrashLeviathan avatar Aug 10 '22 15:08 KrashLeviathan

Your writing style is clear an comprehensive. Just what I was looking for. Appreciate your hard work.

netzpace avatar Sep 16 '22 13:09 netzpace

unfortunately Git line endings doesn't help with one scenario:

You are mirroring $hugecompanythatmakesprocessors". The developers in that company mixed CRLF and LF at some times in the past and have not cleaned it up. In order to be able to make sensible merges and diffs, you need the file in the repo to each remain in their original form, while being able to have the files checked out in your local form, and then reconverted back to the original form when checked back in. The only answer is to freeze the whole repo and use an editor that knows what it is doing and follows the original style for that file. Git unfortunately can't help you (though it could). Mix in that some of your subcontractors are working in a windows shop..

jelischer avatar Nov 04 '22 06:11 jelischer

Fantastic and exceptionally comprehensive article. Thank you!

krzychb avatar Nov 06 '22 03:11 krzychb

Very useful. Thank you!

lundgrenmattias avatar Nov 16 '22 08:11 lundgrenmattias

Thanks for the article, it was interesting to read

hyzyla avatar Dec 18 '22 22:12 hyzyla

Extremely useful, @AleksandrHovhannisyan, thanks! Combined with some specific stuff from the docs here, could fix my issue.

paddy-r avatar Dec 21 '22 11:12 paddy-r

Very useful, but all such guides seem to be missing the merge.renormalize configuration variable, which makes renormalizing the standard for all "mergy" operations like merge and cherry-pick.

See here: https://git-scm.com/docs/gitattributes#_merging_branches_with_differing_checkincheckout_attributes

Unfortunately, so far I have not found a way to make it into a .gitattributes entry, or something, so it will be particular to a branch, and centralized/mandatory for all repo clones.

markmaker avatar Mar 27 '23 13:03 markmaker

Thank you for such a great article about .gitattributes at https://www.aleksandrhovhannisyan.com/blog/crlf-vs-lf-normalizing-line-endings-in-git/ it is best and most informative article I have red on tis topic Much appreciated

dbnex14 avatar Aug 02 '23 17:08 dbnex14