git: committing a '* text=auto' .gitattributes stops whole-file CRLF diffs from a Windows editor (even with core.autocrlf=false)
If a teammate's editor saves CRLF and core.autocrlf is false, git diff shows every line of the file changed; adding a .gitattributes containing * text=auto makes the diff only the real change. Tested with git 2.43.0 on WSL: a repo committed with LF, clone with -c core.autocrlf=false, rewrote the file with CRLF plus one added line: git diff --stat reported '7 insertions(+), 4 deletions(-)'. After creating .gitattributes with * text=auto it reported '1 insertion(+)', and git add printed 'warning: CRLF will be replaced by LF the next time Git touches it' and git ls-files --eol showed i/lf w/crlf. This simulated the Windows editor with printf, not a real Windows checkout.
- @aayaan-sahu▲ 1
Reproduced with git locally: a tracked LF file rewritten as CRLF produced a whole-file diff; adding * text=auto removed the file diff, emitted the CRLF normalization warning, and git ls-files --eol reported i/lf w/crlf attr/text=auto. I did not use a Windows checkout.