You clone a repository that was built on Linux, open it on a Windows machine, and Git starts nagging: warning: LF will be replaced by CRLF the next time Git touches it. Then someone commits, and the diff shows every line of a file they never edited. The warning is harmless. The whole-file diffs are not — and neither is the fix everyone reaches for first.
The reflex is to change an editor setting, or to paste a core.autocrlf command from the first search result, or to tell everyone to “just ignore it”. None of those end the churn on a mixed Windows/Linux team, because none of them live in the repository. The fix that works is a committed .gitattributes file plus a one-off renormalisation. Here is why, and exactly how.
Why the warning appears at all
Windows tools historically end a line with two bytes — a carriage return and a line feed, CRLF. Unix and everything born from it use a single line feed, LF. A repository authored on Linux stores LF. When you check it out on Windows with core.autocrlf=true, Git converts LF to CRLF in your working tree so your editor behaves, and it is warning you that when it converts back on commit, those files will be stored as LF again. That is the message. It is informational, not an error, and it corrupts nothing.
Free · 4 minutes
Is your engineering team shipping safely, or quietly accumulating risk?
Fourteen questions on how work gets from idea to production — cadence, testing, rollback, and the key-person risk in your delivery. Banded finding on screen, full sheet by email.
The real damage is different. If two people on the team have different core.autocrlf settings — one on true, one on false, one who never set it — then whoever has the “wrong” setting commits files with the other line ending, and Git records the change to every single line. Now a one-line edit is buried in a two-hundred-line diff, code review is useless, and git blame points at whoever last flipped the endings rather than whoever wrote the logic. That is the war worth ending.
Step one: set core.autocrlf for your role, not from a forum
The core.autocrlf setting is per-machine, and the correct value depends on your operating system. Set it once, globally.
# On a Windows workstation: store LF in the repo, check out CRLF locally
git config --global core.autocrlf true
# On macOS or Linux: store LF, and never rewrite endings on checkout
git config --global core.autocrlf input
# Confirm what you have set
git config --global --get core.autocrlf
Use input on Unix, never true: there is no reason to hand CRLF to a Unix working tree, and input still cleans any stray CRLF out of what you commit. The value false disables conversion entirely, which is what you actually want once the next step is in place. But core.autocrlf is a per-developer setting, and you cannot enforce a per-developer setting across a team. That is the fundamental reason editor tweaks and config one-liners never hold: they fix your machine and no one else’s. Sorting this out properly is the same discipline as setting up a developer environment so it behaves the same for everyone rather than trusting each person to remember the incantation.
Step two: commit a .gitattributes as the source of truth
The fix that travels with the repository is .gitattributes. It sits in the repository root, it is committed like any other file, and its line-ending rules override whatever each developer has in core.autocrlf. Everyone who clones the repo inherits the same behaviour whether they configured their machine or not. This is the committed contract for the repository, the same principle as designing the contract before the code — the rule lives in the repo, not in tribal knowledge.
# .gitattributes — in the repository root, committed to version control
# Auto-detect text files; normalise to LF in the repo AND on checkout,
# on every platform. The eol=lf overrides each developer's core.autocrlf.
* text=auto eol=lf
# Files that must keep CRLF to work on Windows
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf
# Shell scripts must stay LF or they will not run
*.sh text eol=lf
# Never touch genuinely binary formats
*.png binary
*.jpg binary
*.pdf binary
*.zip binary
One judgement call: eol=lf forces LF in the working tree on Windows too, so Windows developers get LF-terminated files locally. Every modern editor — VS Code, Visual Studio, Notepad since Windows 10 — handles that without complaint, and it is the cleanest end state. If you have a specific tool that genuinely cannot cope with LF, drop the eol=lf and write just * text=auto; Git then stores LF but lets each machine’s core.autocrlf decide the checkout ending. Prefer eol=lf unless something forces your hand.
Step three: renormalise the tree that is already polluted
Adding .gitattributes changes the rules going forward, but it does not touch files already committed with the wrong endings. Until you rewrite them, the next edit to any of those files still produces a whole-file diff. The command that fixes the existing tree in one pass is git add --renormalize, which re-applies the line-ending rules to every tracked file and stages only what actually changes.
# Stage the rules first, then rewrite every tracked file to match them
git add .gitattributes
git add --renormalize .
# Check what moved — this should be line endings only, nothing else
git status
# Commit the one-off normalisation on its own, so it is easy to skip in blame
git commit -m "Normalise line endings to LF via .gitattributes"
Do this on a clean tree with no other work in progress, commit it by itself, and warn the team before you push — everyone should commit or stash their own changes, pull the normalisation, and carry on. After that single commit the warnings stop, diffs show only real edits, and it stays that way because the rule is now in the repository rather than in each person’s head. Add merge=union or per-path rules later if you need them; the three steps above are the whole fix.
Why editor settings never fixed it
An editor’s “convert to LF” toggle changes the file on your disk. It does not change what Git stores, it does not travel to your colleagues, and it does not survive the next person who opens the file in a tool set to CRLF. Line endings are a property of the repository, so the fix has to be a property of the repository. Set core.autocrlf to match your operating system, commit a .gitattributes that makes the decision for everyone, and renormalise once. The war ends when the rule stops living on individual laptops — the same reason a baseline you can hand to the whole team beats a setting each person is trusted to remember.
Build and rescue work
Hands-on delivery of this kind is handled by Sixteen Pillars Studio.
Free interactive tool
Website compliance checklist
What your site has to do, based on what it actually does
Answer as much or as little as you like — the list builds as you go. Nothing is stored against your name and no email is required.
Everything that applies
Ordered by what to do first: legal requirements you can close quickly, then larger pieces of work, then what is expected rather than required. Not exhaustive, and not a legal audit.
Dated PDF, yours to keep or circulate.
Most technology problems are not technology problems. They are control problems.
The systems exist. The investment has been made. The question is whether leadership can understand, direct, evidence, and sustain what those systems produce. Find out where control exists — and where it only appears to.