Intermediate · 4 min read
Line endings: LF, CRLF and .gitattributes
Why a file shows as fully changed when you didn't touch it.
The problem
Windows ends lines with CRLF, Linux and macOS with LF. Mix them and every line looks changed in the diff.
Settle it for the whole team
A .gitattributes file at the root wins over everyone's personal config. Store text as LF, and declare binary files.
Safe
$ printf '* text=auto eol=lf\n*.png binary\n' > .gitattributes
Fix files already committed
Re-normalise everything once, in a dedicated commit.
Safe
$ git add --renormalize .$ git commit -m "chore: normalize line endings"