What is the difference between eol=lf and text in a .gitattributes file?
eol
tells Git which line endings to use in your working directory and also enables LF normalization for those files in the repository. This setting applies to a particular path, so I'll use *.txt
in my examples:
*.txt eol=crlf
tells Git to (1) normalize line endings to LF on checkin and (2) convert them to CRLF when the file is checked out.*.txt eol=lf
tells Git to (1) normalize line endings to LF on checkin and (2) prevent conversion to CRLF when the file is checked out.
Notice that both settings normalize line endings to LF on checkin! This effectively sets the text
attribute because text
does the same thing.
Since these settings only apply to changes going forward, additional steps would be needed to update files that are already checked in.
And one more thing... Be careful to set eol
only on paths matching text files. It enables normalization without any content checks, but binary files should not be normalized. Depending on your paths, you might need to explicitly exclude certain file types:
# Disable eol normalization for these types:*.png -text*.jpg -text*.ttf -text