gitline-endingsgitattributes

How to normalize working tree line endings in Git?


I have cloned a repository that had inconsistend line endings. I have added a .gitattributes that sets the text attribute for the files I want to normalize. Now when I commit changes I get the message:

warning: CRLF will be replaced by LF in FILE.
The file will have its original line endings in your working directory.

How can I make git normalize my working copy of the file for me? Preferably I would like git to normalize the entire working tree.


Solution

  • With Git client 2.16 and higher there is now a much simpler way to do this. Just use:

    git add --renormalize .
    

    Note: it's better to do this with a clean workspace. For details, see: