git line ending warning (CRLF / LF) — how to fix

# Linux / macOS — convert CRLF to LF on commit, never on checkout
git config --global core.autocrlf input

# Windows — convert LF to CRLF on checkout, back to LF on commit
git config --global core.autocrlf true
warning: LF will be replaced by CRLF in src/app.ts.
The file will have its original line endings in your working directory.

Git is converting line endings because core.autocrlf is set to true on a non-Windows machine, or vice versa.

Use .gitattributes for consistent cross-platform settings

A .gitattributes file enforces line endings regardless of individual developer settings.

# .gitattributes
* text=auto eol=lf
*.bat text eol=crlf

Normalize existing files in the repository

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

Disable warnings (not recommended)

git config --global core.safecrlf false