Skip to main content
Git & Version Control · Developer Error Resolution Lab

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.

Triggered Error Message:

warning: in the working copy of 'src/app/page.tsx', LF will be replaced by CRLF the next time Git touches it

Customize Solution for Your Environment
# 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?
No, it is informational. But mixed line endings create noisy diffs and can break shell scripts in Linux containers, so normalizing is recommended.
DEVSECOPS & CI/CD PARTNER2 Slots Open

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.

Browse All 69 Guides