Line endings: CR, LF, and the ASCII feud that still haunts git
Line endings: CR, LF, and the ASCII feud that still haunts git
At some point, if you've ever committed code, git will hand you a message that reads like a prophecy: LF will be replaced by CRLF. It makes no sense on its face. Who is LF? Why would anything replace it? And why does git, of all tools, care? The answer is a grudge match between two invisible ASCII characters — a feud that has been running for the better part of a century, outliving every machine that started it. This is the entire line ending history in one sitting: the hardware, the split, the internet's strange loyalty, and why your repository still carries the scars. Come with me. It gets weird.
Two ghosts, one moving carriage
Let's start with the hardware, because the feud is really about physics. ASCII hands every character a number, and hidden among the 128 codes are two ghosts. LF, line feed, is code 10. CR, carriage return, is code 13. Neither one draws a mark on your screen. Both were born to command a physical machine: the teleprinter, which was the internet of the 1950s and 60s. Open a file in a hex editor today and you'll see their fingerprints everywhere — the byte 0A for LF, 0D for CR — little two-digit tombstones of a war fought with metal.
Picture a typewriter, but heavy, roaring, motorized, hammering out sixty characters a second onto a roll of paper. It has a carriage — the entire mechanism that holds the paper — and the print head travels across it, left to right, one character at a time. To start a fresh line you have to do two completely separate physical things: shove the carriage all the way back to the left edge, and roll the paper up one line. Two motions, so two commands. CR slams the carriage home. LF advances the paper. Do both and you're at the start of a clean row. That's why the CR LF ascii pairing exists at all: a new line was never one character. It was a two-step dance.
And the machines demanded the full dance, every single time. CR alone meant the next character would overprint what you just wrote. LF alone sent the text marching down the page in a diagonal staircase, like a staircase built by a drunk architect. Teleprinters were dumb, faithful, and exacting. So the earliest standards for transmitting text carried the whole ritual — carriage return line feed, every line, forever. Nobody wrote that down as a choice. It was just what the machines needed, the way a horse needs both a bit and a rein.
The great schism: three tribes, one newline
Now the feud begins. Once computers stopped printing on paper and started storing text as files, "how does a line end?" became a question of taste — and in computing, taste becomes theology.
Unix, which grew up at Bell Labs in the early seventies, decided the carriage return was wasted motion. There's no physical carriage anymore; the CR is just a byte that does nothing. So Unix decreed: a new line is LF, one byte, done. Windows — via DOS, which inherited its file habits from CP/M, which inherited them from the teleprinters — kept the full carriage return line feed ritual of the old age. And the classic Macintosh, before OS X, went a third way and used CR alone. Three tribes. Three ways to end a line. The whole cr lf ascii question, settled three different ways by three cultures that rarely talked to each other. The Mac's lonely CR was the strangest choice of all — as if a whole platform wanted to be different so badly that it invented a third way to say "new line" that nobody else would ever use. It's one of the quietest, longest-running schisms in line ending history, and it's still arguing today.
For the record, the Unix side had the better engineering argument. In the 1970s and 80s, disk space was a budget you watched, not a rounding error. Dropping the CR saved one byte on every single line of every file; across a system with millions of lines, that's real money in storage. And it made processing simpler — every line is one clean marker, nothing else, and you never have to ask "is that CRLF or LF or CR?" The Windows side kept the old ritual because the files already had it, and compatibility is a hell of a drug. As far as I remember, it was pure inertia plus a fear of breaking every piece of software that assumed the old format. Both choices were reasonable in their moment. The feud is what happened after.
The internet picks a side, and it gets weird
Here's where it gets weird. The internet — that great neutral meeting ground — actually picked a team. The protocols underneath the web, HTTP and SMTP, still demand the old CR LF pair as the line terminator in their headers. It's written into the RFCs. Not because anyone loves CRLF, but because the early standards were drafted by people raised on teleprinters, and nobody has been brave enough to change them since. Changing it would break every server, every proxy, every log parser on Earth, all at once. So the web runs on a typewriter habit. Sixty years later, the most modern network on the planet still bows to a piece of 1950s office furniture.
And it's not just the web. Old-school protocols like telnet and FTP wrote text with the full ritual too, and so did email for decades. Every message you've ever sent passed through plumbing that insisted on CRLF somewhere inside it. The whole world standardized on the typewriter's two-step, then spent fifty years pretending it didn't.
And the feud produces genuine security bugs. There's a whole vulnerability class called CRLF injection: if a program lets you write raw characters into an HTTP header, and you sneak in a CR and an LF, you can cut the header short and inject one of your own. One invisible character becomes a weapon. When security folks tell you that line endings can get you hacked, they're not being dramatic — the ritual is still doing real work on every single request you make to a website, and it can still bite.
I remember the first time I opened a Unix file on a Windows machine, back in the dial-up days, and saw the whole thing littered with ^M symbols. That's caret notation for CR — the visible ghost of the carriage return. The file looked like a graveyard of tiny markers, one per line, as if every sentence had died and left a headstone. If you've ever seen ^M, congratulations: you've witnessed the feud in the wild, in its native habitat.
Git enters the fight, badly
Now the part of the line ending history that actually haunts you: git. Git stores text as bytes, and bytes don't care about your feelings. A Windows user's editor writes CRLF endings; a Unix or Mac user's editor writes LF. Git looks at the changed file, sees every line as modified, and reports a conflict — over literally nothing. I once burned an entire afternoon on a merge conflict that was one invisible character per line. Two files that read identically, differing only in ghosts. That's not a war story, that's a Tuesday.
Git's answer was to try to be everybody's friend, and it's been apologizing ever since. There's a setting, core.autocrlf, that quietly converts endings as files go in and out of your working copy. It works, most of the time — and then it delivers the prophecy: LF will be replaced by CRLF. That message isn't a warning about your code. It's git telling you it's about to rewrite your file's endings and asking you to be okay with it. Half the time you will be. The other half, you will be very much not okay.
The grown-up answer is a file called .gitattributes, where you tell git exactly which files are text and which ending they deserve. Normalize the repository to LF, let git convert on checkout if your editor needs it, and the feud mostly goes quiet. I remember normalizing an old repo in a single commit years ago — thousands of files, one enormous diff that touched everything and changed nothing you could see. It felt like exorcising a house. I'll say it plainly: a repo with a good .gitattributes has never once made me sad. The repos that skip it are where the ascii line endings debate lives on, forever, in every pull request, every diff, every quiet hour of debugging something that was never actually broken.
The fix, when it happens, is boring and beautiful. You write the .gitattributes, commit a one-time normalization, and from that moment the repository has exactly one opinion: LF inside the repo, whatever your editor wants in your working copy. After that, the prophecy goes silent. New contributors stop producing phantom conflicts. It's the closest thing this feud has to a peace treaty.
What this has to do with text art
If you came here from the ascii.im side of the internet, you might wonder why a text-art person should care about line endings at all. The answer: text art is plain text, and plain text is the battlefield. A piece drawn with LF endings opens clean anywhere. Start mixing — a CRLF file pasted into an LF one, two editors with different opinions about the world — and you get invisible breaks, ragged lines, art that falls apart in the middle. In this medium the pixel is a character and the newline is the canvas edge. If the canvas edge lies, the picture lies.
That's why ascii.im studio writes clean files, why the text pixel art guide treats endings as part of the craft, and why the pricing plans I put real thought into assume a serious artist cares about this stuff. Text art is one of the last places where ascii line endings still visibly matter to a human eye — you can see the damage with your own eyes, no hex editor required. Every other file on your machine hides the feud from you. An ASCII drawing can't. It's honest, which is exactly why I love it.
And there's a sneaky modern twist: chat apps and websites love to mangle endings when you copy-paste art. Paste a drawing into a comment box and the site's editor happily rewrites every newline, and suddenly your nice box art has a staircase running down the right side. The feud doesn't even need git to reach you anymore — it rides in on every clipboard.
So here we are, decades in. A metal carriage that nobody builds anymore still decides how your code looks to git. Two invisible characters, one ancient machine, and a feud that outlived every machine involved. Next time git warns you about LF and CRLF, you'll know exactly what it's fighting about: two ghosts from a teleprinter, still arguing over the same line. Which raises the question I ask everyone who watches this channel — which tribe are you in? LF purist, CRLF traditionalist, or the "let .gitattributes sort it out" peacemaker? I'm the third one. But I'm curious. Drop a line — preferably with LF endings, though I won't hold a grudge. That's the thing about this feud. It never really ends. It just gets managed.