git - What is the difference between eol=lf and text in a .gitattributes file? -
according the documentation on .gitattributes, text
enables end-of-line normalization:
text
setting text attribute on path enables end-of-line normalization , marks path text file. end-of-line conversion takes place without guessing content type.
according same documentation, eol=lf
normalize linebreaks:
eol
this attribute sets specific line-ending style used in working directory. enables end-of-line normalization without content checks, setting text attribute.
the fact examples given mix them in same file seems imply there (perhaps subtle) difference between them:
*.txt text *.vcproj eol=crlf *.sh eol=lf *.jpg -text
also, there seems unambiguous statement same, or text
shorthand eol=lf
—though appears case. closest thing find such statement quoted above, says "effectively setting text attribute". word effectively seems back-pedal slightly, though it's not actually setting text attribute, more-or-less setting it, or having same effect.
what, precisely, difference between these two? (or text
shorthand common use case?) there reason mix 2 in 1 .gitattributes
file?
or: text
require git guess kind of linebreak need, while eol
(obviously) specifies?
eol
tells git line endings use in working directory , also enables lf normalization files in repository. setting applies particular path, i'll use *.txt
in examples:
*.txt eol=crlf
tells git (1) normalize line endings lf on checkin , (2) convert them crlf when file checked out.*.txt eol=lf
tells git (1) normalize line endings lf on checkin , (2) prevent conversion crlf when file checked out.
notice both settings normalize line endings lf on checkin! sets text
attribute because text
same thing.
since these settings apply changes going forward, additional steps needed update files checked in.
and 1 more thing... careful set eol
on paths matching text files. enables normalization without content checks, binary files should not normalized. depending on paths, might need explicitly exclude file types:
# disable eol normalization these types: *.png -text *.jpg -text *.ttf -text
Comments
Post a Comment