Reputation: 2369
I'm on Windows. I have set my core.eol
to native
. I have set my core.autocrlf
to false
. I'm pretty sure I started out with files containing CRLF line endings, all of them being one of .clj
, .md
, or .gitignore
. I committed them. Then in the next commit I committed the following .gitattributes
* text=auto
*.bat text
*.bib text
*.clj text
*.java text
*.md text
*.tex text
*.txt text
*.jpg binary
*.pdf binary
*.png binary
In that commit, the diff said every line of every file changed (the line endings I assume).
Having set core.eol
to native
, I thought I would get CRLF in my working tree, but that is not the case (only for the .gitattributes
file, no other file, including .gitignore
). I didn't notice earlier because I'm using Vim.
I thought the diff for the gitattributes commit looked ugly, so I tried setting different values for core.autocrlf
and core.eol
, for example setting them to true
and crlf
respectively, and doing git filter-branch --tree-filter HEAD
. I got the error error: core.autocrlf=input conflicts with core.eol=crlf
. I checked with git config --get core.autocrlf
and that returned true
. So why do I get the error?
I'm very confused. What I want is CRLF line endings in my working tree, and commits that don't change my line endings, i.e. they are LF when committed right from the start, and stay that way. How can I achieve that?
Upvotes: 0
Views: 782
Reputation:
This very first line of your .gitattributes
file:
* text=auto
basically ignores your setting for core.autocrlf
and turns on line ending conversion for all users of your repository, including yourself.
If you don't want automatic line ending conversion, then you shouldn't use that setting in the .gitattributes
file.
See Dealing with line endings and gitattributes Manual Page for more details.
Upvotes: 1