For what you are trying to do, I think you need the following. Note that the eol attribute according to the gitattributes man page can be either "lf" or "crlf". Native is for configuring core.eol.
Set core.autocrlf false to explicitly control normalization. Now only files marked with the text attribute will undergo normalization.
Either set the eol attribute explicitly to lf or crlf for certain types of files (for example: shell scripts may require lf to work on unix, .csproj files may require crlf on windows). If the eol attribute is not set, use the value core.eol. If you install core.eol in crlf then your text files will get crlf endings.
Here is an example git test script to illustrate this (from git / t /):
#!/bin/sh test_description='check native crlf setting' . ./test-lib.sh has_cr() { tr '\015' Q <"$1" | grep Q >/dev/null } test_expect_success 'test native elf' ' printf "*.txt text\n" > .gitattributes printf "one\r\ntwo\r\nthree\r\n" > filedos.txt printf "one\ntwo\nthree\n" > fileunix.txt git init && git config core.autocrlf false && git config core.eol crlf && git add . && git commit -m "first" && rm file*.txt && git reset --hard HEAD && has_cr filedos.txt && has_cr fileunix.txt ' test_done
With the above configuration and attributes with git for Windows 1.8.0, both files are normalized after reset and contain crlf line endings.
Where an error may exist is that if the core.eol variable is not set (or set to "native"), this test will fail because the files in this case are normalized to the end of the lf line. The path you mentioned above does not help either. Therefore, from my testing, you should explicitly specify core.eol in crlf so that your planned approach is successful.
patthoyts
source share