Is there a way to enforce core.autocrlf=input
from within the .gitattributes
in order to propagate the policy throughout my colleagues?
In detail what I want is to convert to lf
on add and leave as is
on checkout.
The problem is that neither text
nor eol
do what I want in .gitattributes
since eol
has 3 acceptable values:
lf
crlf
native
Ideally I would like my .gitattributes
file to look like this:
* text eol=asis
Git doesn't convert on commit, but rather on
git add
. (More precisely, it does conversions on operations that copy the object into the repository and produce a hash value—but for most purposes, that's justgit add
anyway.) At this time it applies any "clean" filters and does input-side EOL operations. (Likewise, output-side "smudge" filters and EOL operations occur when copying out from the repository to the work-tree, which for most purposes isgit checkout
andgit reset --hard
.)According to the gitattributes documentation, setting
eol=lf
:Hence, though I have not actually tested this, it sounds like
* eol=lf
is just what you want. Note that this is different fromcore.eol
, which behaves as you described in your question; this is only for a.gitattributes
setting, which applies to the files that match the name-pattern.