Enforce core.autocrlf=input through .gitattributes

前端 未结 3 2069
梦毁少年i
梦毁少年i 2021-02-14 10:42

Is there a way to enforce core.autocrlf=input from within the .gitattributes in order to propagate the policy throughout my colleagues?

In deta

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-14 11:30

    The closest thing to core.autocrlf=input is to use text=auto in .gitattributes.

    That specifies they are text files, so new files will be put in the repo with LF line endings. And, according to The gitattributes documentation, by setting text=auto:

    When the file has been committed with CRLF, no conversion is done.

    We converted a Mercurial repo to Git recently. Mercurial does no eol conversions, so many of our files already had CRLF after the conversion. Setting text=auto for those file extensions allows new files to still be normalized to LF, but doesn't touch the existing files, and doesn't show them as modified in the current directory.

提交回复
热议问题