I am working on Windows 7 and to prevent EOL problems I have a .gitattributes
file set up the following way (as described in the github help):
* text=auto
*.js text
But now, when I commit a js
-file that has only LF
line-endings I get the warning:
warning: LF will be replaced by CRLF in XXX.js.
The file will have its original line endings in your working directory.
Well, this sounds to me like I will have CRLF
in my repository and LF
in my working directory, even though it should be (and I want it to be) the exact other way around. The js
-file's line endings are still LF
after the commit.
Am I reading the warning wrong or did I set up .gitattributes
in the wrong way?
Thanks!
p.s. my global git config has autocrlf = true
, but that should not effect the EOL-conversion when committing because of the .gitattributes
file
p.p.s the js
file is in a subdirectory
You should disable autocrlf
– It is not causing this “situation”, but it does collide with the gitattributes setting and adds no benefits.
You don’t have any problem with EOL conversion in your repo. The message you quoted is telling you, that if you check out this file again (with these settings), you will have CRLF in your working directory. But for now it will stay at LF.
If you want to know what line endings stuff has in your repo, run this:
git show commit:path/to/file | file -k -
If you want to get rid of that message, set your editor to save files with CRLF. Or better: If all your tools support LF endings, set this repo to use LF on checkout (if you accidentally save a file with CRLF, it will still be normalized):
git config core.eol lf
Note: this will probably only work if you set core.autocrlf
to false