March 03, 2025

Git warning about LF and CRLF

Photo Credit: Dall-E by OpenAI

What’s This Warning?

Git warns:

warning: in the working copy of 'gatsby-config.js', LF will be replaced by CRLF

This happens because Linux/macOS use LF, while Windows uses CRLF for line endings.

What Does This Mean?

This warning appears when your repository has files with LF (Line Feed) line endings, but your local system (likely Windows) is set to use CRLF (Carriage Return + Line Feed). Git is informing you that when it updates the file, it will convert the line endings accordingly.

Why Does This Happen?

Different operating systems use different conventions for line endings:

  • Linux/macOS: LF (\n)
  • Windows: CRLF (\r\n)

How to Fix It

  • Keep LF (recommended for cross-platform projects):

    git config --global core.autocrlf input
  • Use Windows-style CRLF:

    git config --global core.autocrlf true
  • Enforce LF in a repo:

    echo "* text=auto" > .gitattributes

Peace... 🍀

Tech Innovation Hub
Modern Software Architecture

Exploring cutting-edge technologies and architectural patterns that drive innovation in software development.

Projects

© 2025 Tech Innovation Hub. Built with Gatsby and modern web technologies.