Reputation: 1020
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?
Upvotes: 1
Views: 669
Reputation: 1020
For the enable-case, you must execute git reset --hard
, as opposed to the disable-case, where you can just run git checkout .
Upvotes: 1
Reputation: 1323953
How can I reset working directory line endings in the enable case?
As I mentioned in "Git: how to renormalize line endings in all files in all revisions?", since Git 2.16 (Q1 2018), you would use git add --renormalize .
(instead of git rm --cached -rf .; git add .
)
I would recommend using .gitattributes
directives only (as in here), and keep core.autocrlf
to false
, as I have always recommended.
Upvotes: 0