'Change CRLF to LF of all the files in repo

My repo has lots of files with CRLF. I want them to be changed to LF.

I tried to change in my working copy and commit them but the changes are ignored by git. The files with only change eol can be staged but can't be committed, right?

I can change eol and add another change on the first commit then I revert the change except for eol before next commit. But it's so dirty solution.

Why does git ignore the eol changes? Any good workaround for this?

I know core.eol and core.autocrlf in config and * text=auto in .gitattributes but they don't help me.



Solution 1:[1]

You have to refresh your repository after changing line endings after setting core.autocrlf. This can be done using

git add --renormalize .
git commit -m "Normalize all the line endings"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jloh