gpt4 book ai didi

linux - 如何让 Git 在 Linux 上将 CRLF 文件转换为 LF?

转载 作者:太空狗 更新时间:2023-10-29 11:18:46 24 4
gpt4 key购买 nike

我正在尝试做一些非常简单的事情:检查一个具有 CRLF 结尾(并且没有 .gitattributes)文件的 repo,并以 native (LF) 行结尾结束。我什至不想 promise 。

我读过 Github's suggestion , 和 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 认为它是二进制的。
见:

即使使用带有 *.js 文本.gitattributes,它仍然会保留 crlf

但是对于 *.js eol=lf,这实际上会强制转换。

参见“Can git's .gitattributes treat all files as binary except a few exceptions?”。

关于linux - 如何让 Git 在 Linux 上将 CRLF 文件转换为 LF?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28511463/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com