Search code examples
gitline-endings

Force commit with CRLF


How do I configure Git to following behavior:

  • Checkout as-is
  • Commit as CRLF

Until now I've been using core.autocrlf=false, however version control police is now demanding all commits to be in CRLF format. Note that this is a TFS repo I am connecting to through Git locally. I tried configuring it as

[core]
    autocrlf=input
    eol=CRLF

which is I think what I want, but I get this error on commit error: core.autocrlf=input conflicts with core.eol=crlf


Solution

  • Just unset (remove) core.autocrlf:

    git config --unset core.autocrlf
    

    and the error message will go away. It will use CRLF line endings for your files, provided that core.eol is set to crlf

    core.eol is meant to override core.autocrlf, but due to a bug they seem to conflict.