Reputation: 1006
Git refuses to strip out windows style line endings and commit with unix style line endings.
Before anyone says to set my config files... I have run both of these commands and verified that they are putting the settings correctly in my configs:
git config --global core.autocrlf true
git config core.autocrlf true
The weird thing is... if I make a new repo using git init and then I copy a file from the repo I'm trying to work in with windows line endings to the new repo, it works when I commit in that new repo!
When I run:
git add .
git usually tells me something like:
warning: CRLF will be replaced by LF in fileWithWindowsLineEndings.txt.
The file will have its original line endings in your working directory.
But this does not happen with the one repo I'm trying to work with. Does it matter if files that I checkout may have come from the repo with windows line endings? My guess is that someone on my team didn't set up their git config right and committed and pushed windows line endings.
Any Ideas?
Thanks.
Upvotes: 3
Views: 2177
Reputation: 1515
I just tried this; if you add a file without having core.autocrlf
set, it will not convert this file later, even if core.autocrlf
is set then. You must remove the files from the Git repo and re-add them.
Edit after a comment:
You can solve this using a .gitattributes file: https://help.github.com/articles/dealing-with-line-endings
Upvotes: 3