Monday, December 24, 2012

Git - Fixing the crlf, linebreak, eol nightware

Problem:

Windows, Linux, and Mac have different ways to represent line breaks (end-of-line).  Windows use CRLF, linux and Mac use LF.

When developers are checking in code using different operating systems, a git diff will show lines with different line break representations to be different.

To compare without caring about the line breaks, use
git diff --ignore-space-at-eol

To clean and rebuild the directory:

Set text=auto in .gitattributes
echo "* text=auto" << .gitattributes

Remove the Git index:
rm .git/index

Rebuild the index
git reset

Commit the changes:
git add .
git commit
You should see the following:
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in  

No comments:

Post a Comment