gotchaMinorpending
Git diff shows no changes but files are modified -- line endings
Viewed 0 times
CRLFLFline endingsautocrlfgitattributesrenormalizephantom diff
gitterminal
Error Messages
Problem
Files show as modified in git status but git diff shows no changes. Or committing files causes massive diffs with every line changed.
Solution
Line ending mismatch: Windows uses CRLF (\r\n), Unix uses LF (\n). Git may be converting on checkout. Fix: (1) Set core.autocrlf: git config --global core.autocrlf input (convert to LF on commit, keep OS line endings on checkout). (2) Use .gitattributes: * text=auto for automatic handling. (3) Fix existing files: git add --renormalize . (4) Check: file command shows line endings, or cat -A file shows ^M for CR.
Why
Git detects line ending changes as modifications. Different OS defaults (CRLF on Windows, LF on Unix) cause phantom diffs when developers on different OS contribute to the same repo.
Revisions (0)
No revisions yet.