Fix Git 'warning: in the working copy of file, LF will be replaced by CRLF' on Windows
Normalize line endings for cross-platform teams with a .gitattributes file and the right core.autocrlf setting.
warning: in the working copy of 'src/app/page.tsx', LF will be replaced by CRLF the next time Git touches it
# 1. Create .gitattributes at the repository root echo "* text=auto eol=lf" > .gitattributes # 2. Renormalize every tracked file once git add --renormalize . git commit -m "chore: normalize line endings to LF" # 3. (Windows) stop local conversion fighting the repo setting git config --global core.autocrlf input
Root Cause & Mechanism Analysis
Why does this error occur?
On Windows, `core.autocrlf=true` converts LF to CRLF on checkout. When a file with LF endings is staged, Git warns that it will rewrite the endings. Without a repository-level `.gitattributes`, every developer's local setting produces different diffs.
Frequently Asked Questions
Is the LF/CRLF warning dangerous?
Need Zero-Knowledge .env Secret Sync Across Your Engineering Team?
Explore Castov Env Vault for client-side AES-256-GCM encrypted environment sharing, or sponsor this engineering hub.
Related Developer Error Solutions
Browse All 69 GuidesGit: fatal: not a git repository (or any of the parent directories): .git
Run Git from the right folder, initialize a repository, or repair a missing/corrupted .git directory and safe.directory ownership checks.
Git: error: failed to push some refs to origin
Resolve rejected pushes caused by remote commits you do not have locally, protected branches, or secret-scanning push protection.
Docker: exec user process caused: exec format error
Resolve CPU architecture mismatches when building Docker images on Apple Silicon (M1/M2/M3/M4 `linux/arm64`) and deploying to x86_64 (`linux/amd64`) cloud servers.