git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Why doesn't git core.eol=lf work?

From
Lidong Yan <yldhome2d2@gmail.com>
Date
Jul 13, 2025, 07:43 UTC
Message-ID
<C41F422E-8C9D-4BC7-BA0B-57B7D13D6557@gmail.com>
In-Reply-To
<sAxC2ASixUyCVtsk22zrxI2vAeM546T7O2tyWIS2vv_TGFo2OXWegg8J_r0zGzo5bZOA-BrwHa5yjAv2-Ewusjv9Fa9YYocrRkaIfpxhv_c=@proton.me>
Jason Cho <jason11choca@proton.me> write:
Show 26 quoted lines
> 
>> 
>> Since you posted `git diff` output, may I ask if your concern is
>> actually the ^M in the diff output, which you intend to fix with
>> automatic CRLF-to-LF conversion?
>> 
> 
> No, my intent is to find moved or duplicated text among files. 
> 
> Let's say license_header.txt has 
> 
> DBeaver - Universal Database Manager^M
> Copyright (C) 2010-2018 Serge Rider (serge@jkiss.org)
> 
> and another.txt has
> 
> DBeaver - Universal Database Manager
> Copyright (C) 2010-2018 Serge Rider (serge@jkiss.org)
> 
> My tool doesn't think the two pieces of txt the same because of ^M.
> 
> Although my tool can do normalization internally, if git checks out files to CRLF due to core.autocrlf=true, my tool is fighting against git. git shouldn't spend time converting to CRLF which is about to be converted back to LF by my tool.
> 
> That's why I set core.autocrlf=false, and ask git to normalize files to LF.
> 
> So the problem is that, conversion to LF is not happening.

I believe that it's impossible to check out CRLF from the index as LF. You have to use your tool to do that.

The definition of core.eol=lf is here:
  https://git-scm.com/docs/gitattributes/2.9.5#:~:text=Set,-to%20string%20value%20%22lf

This means that when you use git add to stage files, Git will convert CRLF line endings to LF. However, when you check out files, Git will leave the line endings unchanged.

Thanks, Lidong

Previous: Jason ChoNext: Jason Cho
Message 6 of 7 in “Why doesn't git core.eol=lf work?”
  1. Jason ChoJul 12, 2025
  2. Torsten BögershausenJul 12, 2025
  3. Jason ChoJul 12, 2025
  4. Johannes SixtJul 12, 2025
  5. Jason ChoJul 12, 2025
  6. Lidong YanJul 13, 2025
  7. Jason ChoJul 13, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.