I have Windows machine with VS project and I use both Visual Studio and tools from Cygwin environment including Git. Sometimes I get different line endings in files after editing. I want simple solution to check files' line ending consistency before they go to the repo. Git's core.safecrlf
is the right thing I suppose.
Now I have a strange behavior:
Files A
and B
with following parameters:
$file A
A: HTML document, UTF-8 Unicode text, with CRLF line terminators
$file B
B: HTML document, UTF-8 Unicode (with BOM) text, with CRLF line terminators
File A is already in repo, file B is new one. Note, both have CRLF line endings. Now try to stage them, core.safecrlf
is true
.
$git add A # ok
$git add B # fails
fatal: CRLF would be replaced by LF in B.
Am using core.safecrlf
correctly? Or maybe I need to write hook to check files?
Notes:
- tried with different file encodings (with and without BOM), no difference.
- there's related
core.autocrlf
feature in Git, added it to tags (Stackoverflow has no tag forcore.safecrlf
) - git version 1.8.5.rc1.17.g0ecd94d (compiled from sources under Cygwin)
EDIT #1: checked out core.autocrlf
- it was input
. Changed to false
, now I can add both files. Why?
eol=
attribute simply determines what you get in the worktree. As for compatibility, newer versions still interpret the oldcore.autocrlf
in a sensible manner. – Confabulation