Interview Prep/Git & GitHub/Config, Line Endings, Files and Platform Quirks

Right after a fresh clone, `git status` shows files as modified, and `git restore .` or `git reset --hard` cannot make them clean.

AdvancedTroubleshootingConfig, Line Endings, Files and Platform Quirks
Answer

Likely causes → The files were committed with CRLF line endings, but .gitattributes (* text=auto or eol=lf) says they should be normalized to LF in the repo. Every checkout produces a working file that, once normalized, differs from the CRLF blob in the index, so Git reports it as modified.

Diagnose →

git ls-files --eol | grep 'i/crlf'
git diff --ignore-cr-at-eol --stat    # empty = only line endings differ

Fix → Normalize the repo once and commit:

git add --renormalize .
git commit -m "Renormalize line endings"

Prevent → Commit .gitattributes at repo creation and add a CI check that git ls-files --eol contains no i/crlf for text files.

All Git & GitHub questions Roadmap: Git & GitHub

More on Config, Line Endings, Files and Platform Quirks