fatal: CRLF would be replaced by LF

I remember it was a Friday, I wanted to commit my changes and go home to start a good weekend.

When I tried to add new files to my local git repository, I experienced this issue:

1
2
$> git add .
fatal: CRLF would be replaced by LF in /core/sites/all/modules/thirdlibrary/file.xyz

After researching a bit, I discovered that the problem was being caused by a third library included in my project and for some reason Git didn’t want to include those files in my repository.

According to the inexhaustible knowledge of StackOverflow, here and
also here explain the problem and how to solve it.

Commonly this issue is produced by how the end of line is treated on different operative systems. If you ever encounter this problem, I suggest you do the following:

1.- Install dos2unix. It’s a DOS/MAC to UNIX and vice versa text file format converter.

1
$> sudo apt-get install dos2unix

2.- Check your files with dos2unix tool. Make sure that dos2unix checks all files on your conflictive folder.
Those files who are ok, dos2unix will not change it.

1
$> find  /core/sites/all/modules -type f -exec dos2unix {} +

The problem will be gone the next time you try to add your files to your git repository.