CRLF vs LF on Windows

The symptom

What you see

Terminal
$ warning: in the working copy of 'src/app.js', LF will be replaced by CRLF
$ the next time Git touches it
In VS Code
  1. The warnings show in the Output panel (Git channel)
  2. The status bar (bottom-right) shows CRLF or LF for the open file

This is Git's message, not commands to run. Older Git prints the shorter 'warning: LF will be replaced by CRLF in src/app.js'.

What it means

Every line of a text file ends with an invisible character — and the two worlds disagree about which one. Windows ends lines with CRLF ("carriage return + line feed"); Mac and Linux use just LF. Git is warning you that it plans to normalize the endings so that you and a teammate on a different system don't constantly see phantom changes in each other's files.

Is anything wrong? No.

It's a warning, not an error. Your code runs identically either way, the commit succeeds, and nothing is corrupted. The only real annoyance line endings ever cause is cosmetic: a diff that claims every line of a file changed when you only edited one (see the tip below).

The set-and-forget fix

Tell Git your preference once

Terminal
$ git config --global core.autocrlf true    # Windows
$ # Mac/Linux use: git config --global core.autocrlf input
In VS Code
  1. The status-bar CRLF/LF indicator converts the open file when clicked
  2. The Files: Eol setting controls what new files use

autocrlf true = store LF in the repo, give you CRLF on disk. The warnings quiet down once files are consistent.

Team-proof it: .gitattributes

Your core.autocrlf setting lives on your machine. To make the whole team consistent regardless of their settings, commit a one-line .gitattributes file at the repo root:

.gitattributes

Terminal
$ * text=auto
In VS Code
  1. Explorer → New File → name it .gitattributes
  2. Paste the line, save, commit it like any file

File contents for a .gitattributes file — not commands. It tells Git to normalize all text files for everyone.

Tip: a diff showing every line of a file as changed is almost always line endings, not real edits. Normalize the file (save it once with the right ending) and the diff shrinks back to your actual change.

Up next: your branch says master, every tutorial says main — the four-command rename.

FAQ

Frequently Asked Questions

Is the "LF will be replaced by CRLF" warning a problem?
No — it's informational. Git is telling you it will normalize the invisible end-of-line characters so files stay consistent across Windows, Mac and Linux. Your code runs identically either way.
What are CRLF and LF?
The invisible characters that end each line of a text file: Windows uses CRLF (carriage return + line feed), Mac and Linux use just LF. Editors handle both — the warning is only about keeping the repo consistent.
Why does my diff show the whole file as changed?
Almost always line endings: every line's ending flipped between CRLF and LF, so Git sees every line as different. Normalize the file (save it once with the right ending, or commit a .gitattributes with * text=auto) and the diff shrinks to your real edits.
Which autocrlf setting should I use?
Windows: git config --global core.autocrlf true (LF in the repo, CRLF on your disk). Mac/Linux: core.autocrlf input. Teams should also commit a .gitattributes with * text=auto so it works regardless of anyone's settings.