Notes

Git - ensure LF on Windows

author: Paul Kim

categories: git

tags: git

Problem

On Windows, you might get the following warning when you stage files that were checked out from Git:

warning: LF will be replaced by CRLF in path/to/file.ext.
The file will have its original line endings in your working directory

Solution

1. Find .gitconfig location

Find out where .gitconfig file is located:

git config --list --show-origin
os .gitconfig location
Windows C:\Program Files\Git\mingw64\etc\gitconfig
C:\ProgramData\Git\config
%HOMEPATH%\.gitconfig
Mac /usr/local/etc/gitconfig
~/.gitconfig
Ubuntu ~/.gitconfig

2. Update .gitconfig

Run the following commands to ensure LF on Windows

git config --global core.autocrlf false
git config --global core.eol lf

Your .gitconfig file should have the following:

[core]
    autocrlf = false
    eol = lf

3. Update .gitattributes

Add the following to the first line of .gitattributes:

* text=auto
Source

ChromeEdgeFirefoxOpera

© 2021 paulkode.com. All rights reserved.