gitcore.autocrlf

Reset line endings in the working directory when *enabling* core.autocrlf


Regarding core.autocrlf and working directory line-endings, I am seeing some strange, asymmetrical behavior when checking out files from the index.

When disabling auto-crlf, the following works as expected:

git config core.autocrlf # true
git config core.eol # crlf
git clone <repo_url>
cd <repo>
git config core.autocrlf false
git checkout . # Updated N paths from the index.

However, the inverse is not true. The following does not reset line-endings.

git config core.autocrlf # false
git config core.eol # crlf
git clone <repo_url>
cd <repo>
git config core.autocrlf true
git checkout . # Updated 0 paths from the index

How can I reset working directory line endings in the enable case? Is there a reason for this asymmetry that I'm not seeing, or is this a bug?


Solution

  • For the enable-case, you must execute git reset --hard, as opposed to the disable-case, where you can just run git checkout .