git EOL converted the opposit way around? (despite .gitattributes)
* 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?
p.s. my global git config has
autocrlf = true, but that should not effect the EOL-conversion when committing because of the
js file is in a subdirectory
2 Solutions collect form web for “git EOL converted the opposit way around? (despite .gitattributes)”
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
Git is doing exactly what you want to spite its badly worded warning you don’t have to change anything (that warning only talks about the what is happening to the working directory AFAIK not the database).
LF will be in the repo only, if you rm the file and check it out again it will be converted to CRLF in the working tree (only).
I have seen people say don’t change local core settings/global variables when it comes to line endings (article git hub refer to) (I don’t see a conflict with autocrlf) and only use .gitattribute because it makes defaults for the projects your working in, it’s the newer way.
If you want stuff to be LF only you should use a different git attributes line but stick with what you got for your original question it’s fine. (The docs page and your github page seems to say
text eol=lf if you want LF only)
This is a necropost just to say don’t worry it’s sposed to say that 🙂