Git’s line-ending warning won’t shut up. Here’s how to actually fix it.

If you’ve ever committed a file on Windows and gotten a wall of yellow warnings that all say the same thing: warning: LF will be replaced by CRLF. You already know it’s not actually an error. Git still commits the file. It just won’t shut up about it, every single time, for every single file, until you want to throw your laptop.
Here’s what it actually means, and the settings that make it stop for good.
What’s actually happening
Every line in a text file ends with an invisible character (or two) that tells your computer “new line starts here.” Windows has used CRLF (carriage return + line feed) since forever. Mac and Linux, and Git itself internally, use just LF.
Git has a setting, core.autocrlf, that decides whether it should convert between the two automatically when you commit and checkout. The warning shows up when that setting doesn’t match what your files are actually using, so Git is telling you it’s about to convert something and wants you to know.
The fix, most of the time
On Windows, this is usually the right default:
git config --global core.autocrlf true
This tells Git: convert to CRLF when files land on my disk, convert back to LF when I commit. Keeps your local files Windows-normal and the repo itself consistent no matter who else is pulling it on Mac or Linux.
One catch: “usually” isn’t “always.” On a project where a teammate or a build tool is specifically expecting LF line endings locally too, false is the correct setting instead. I’ve hit this on at least one client project where flipping it to true was actually the thing causing problems, not fixing them. If a repo has a .gitattributes file that already specifies line endings per file type, that overrides your local setting anyway and you probably don’t need to touch core.autocrlf at all.
If the warning keeps coming back
Sometimes toggling autocrlf doesn’t fully stick, especially in a repo that’s already got a mix of line endings committed from before you fixed the setting. This combination clears it out:
git config core.autocrlf false
git config core.eol lf
git add --renormalize .
That last command re-applies your line-ending rules across every tracked file in one pass, instead of waiting for you to touch each file individually.
If files suddenly show as “modified” and you didn’t touch them
This is the part that causes actual panic: you open Git and suddenly half your repo shows as changed, with no idea why. Nine times out of ten this is exactly what just happened above: the renormalize pass (or a settings change) touched line endings across the board, and Git is comparing against the old versions.
Resist the urge to reach for anything destructive here. The safe fix is just:
git restore [filename]
…for anything you didn’t actually mean to change. It puts the file back to its last committed state without touching your repo’s history or anyone else’s clone of it. Save the heavier tools for when you actually need them.
Enjoyed this one?
Let J know with some claps