Skip to content
LF will be replaced by CRLF

LF will be replaced by CRLF

DodaTech 3 min read

Git’s “LF will be replaced by CRLF” warning means Git detected a line-ending mismatch between your working tree and your Git config — it’s about to convert them.

What It Means

Different operating systems use different characters to mark the end of a line: Unix-like systems (Linux, macOS) use LF (\n), while Windows uses CRLF (\r\n). When you work on a cross-platform team, this mismatch causes problems — files show as changed when nothing actually changed, or scripts break because Windows tools expect CRLF. Git’s core.autocrlf setting attempts to normalize line endings automatically, and this warning tells you it’s about to do so.

Why It Happens

  • You’re on Windows with core.autocrlf set to true, and a file has LF endings.
  • You’re on Linux/macOS with core.autocrlf set to input, and a file has CRLF endings.
  • A file was committed with mixed line endings.
  • You cloned a repo where some files have LF endings but your Git config expects CRLF.
  • A teammate on a different OS committed files without normalizing line endings.

How to Fix It

Step 1: Check your current autocrlf setting

git config core.autocrlf

Common values:

  • true — Windows: convert LF to CRLF on checkout, CRLF to LF on commit.
  • input — Linux/macOS: don’t convert on checkout, convert CRLF to LF on commit.
  • false — no conversion at all (requires discipline on cross-platform teams).

Step 2: Set the right value for your OS

On Windows:

git config --global core.autocrlf true

On macOS/Linux:

git config --global core.autocrlf input

Step 3: Use a .gitattributes file (recommended for teams)

Create .gitattributes in the repository root to standardize line endings for everyone:

# Auto-detect text files and normalize to LF
* text=auto

# Explicitly declare binary files
*.png binary
*.jpg binary
*.ico binary

# Explicitly declare files that should keep CRLF
*.bat text eol=crlf
*.cmd text eol=crlf

Commit and push the .gitattributes file so every team member uses the same rules.

Step 4: Normalize existing files

After setting up .gitattributes, re-normalize the repository:

git add --renormalize .
git commit -m "Normalize line endings with .gitattributes"

Step 5: Disable the warning (if you don’t care)

git config --global core.safecrlf false

This suppresses the warning but doesn’t fix the root cause — not recommended for shared projects.

What is the difference between LF and CRLF?
LF (Line Feed, \n, 0x0A) is the Unix/Linux/macOS line ending. CRLF (Carriage Return + Line Feed, \r\n, 0x0D 0x0A) is the Windows standard. Git stores files with LF internally by convention. The core.autocrlf setting controls whether Git converts between these when checking files in and out.
Will this warning break my code?
No — it’s a warning, not an error. Git will perform the conversion and your code will work fine. However, if the file is a binary file or a script with a shebang (#!/usr/bin/env ruby), converting line endings could break it. Always use .gitattributes to mark binary files explicitly and avoid conversion on files that need specific line endings.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro