如何在 Linux Git 上将 CRLF 文件转换为 LF?
How to get Git to convert CRLF files to LF, on Linux?
我正在尝试做一些非常简单的事情:检查一个具有 CRLF 结尾(并且没有 .gitattributes)文件的 repo,并以本机 (LF) 行结尾结尾。我什至不想承诺。
我读过 Github's suggestion, and Tim Clem's article,但它们似乎主要针对 Windows 开发人员。
我试过这个:
$ git config --global core.autocrlf=input
$ git clone https://github.com/DennisSchiefer/Project-OSRM-Web.git
但是没有 - 我关心的文件 OSRM.Config.js 仍然有 CRLF 结尾。
尝试 core.autocrlf=true
没有帮助。
即使添加并提交 .gitattributes
文件(然后 git rm --cached -r . && git reset --hard
)也无济于事。
我找不到任何实际上会在此文件中留下 LF 行结尾的组合。
core.autocrlf
将强制 git 处理所有 text 文件。
如果OSRM.Config.js没有被处理,那意味着Git认为它是二进制的。
参见:
- "How to determine if Git handles a file as binary or as text?"
- "Why does Git treat this text file as a binary file?"
即使 .gitattributes
和 *.js text
,仍然会保持 crlf
。
但是对于 *.js eol=lf
,这实际上会强制转换。
参见“Can git's .gitattributes
treat all files as binary except a few exceptions?”。
我正在尝试做一些非常简单的事情:检查一个具有 CRLF 结尾(并且没有 .gitattributes)文件的 repo,并以本机 (LF) 行结尾结尾。我什至不想承诺。
我读过 Github's suggestion, and Tim Clem's article,但它们似乎主要针对 Windows 开发人员。
我试过这个:
$ git config --global core.autocrlf=input
$ git clone https://github.com/DennisSchiefer/Project-OSRM-Web.git
但是没有 - 我关心的文件 OSRM.Config.js 仍然有 CRLF 结尾。
尝试 core.autocrlf=true
没有帮助。
即使添加并提交 .gitattributes
文件(然后 git rm --cached -r . && git reset --hard
)也无济于事。
我找不到任何实际上会在此文件中留下 LF 行结尾的组合。
core.autocrlf
将强制 git 处理所有 text 文件。
如果OSRM.Config.js没有被处理,那意味着Git认为它是二进制的。
参见:
- "How to determine if Git handles a file as binary or as text?"
- "Why does Git treat this text file as a binary file?"
即使 .gitattributes
和 *.js text
,仍然会保持 crlf
。
但是对于 *.js eol=lf
,这实际上会强制转换。
参见“Can git's .gitattributes
treat all files as binary except a few exceptions?”。