gpt4 book ai didi

git - git 存储库是否具有覆盖全局值的 core.autocrlf 自己的本地值?

转载 作者:太空狗 更新时间:2023-10-29 12:47:31 25 4
gpt4 key购买 nike

根据 this question ,我知道 git 中的 core.autocrlf=true 会导致 CRLF 到 LF 的翻译。

但是当我输入时: git 配置 core.autocrlf

我明白了: 假的

但是,当我暂存已在存储库中的已修改文件时,我仍然会收到以下警告:

Warning: CRLF will be replaced by LF in File1.X.
The file will have its original line endings in your working directory.

我的猜测是该文件的 repo 副本已设置为“autocrlf=true”。

问题: A. 如何查询文件或 git repo 是否已经强制使用 AutoCrlf?B. 如何关闭 autocrlf?

最佳答案

Git 允许您使用 .gitattributes 文件在每个存储库的基础上覆盖您的全局设置。您将它放在存储库的根目录中,并成为作为存储库的一部分提交的文件。我怀疑您的情况正在发生这种情况。

Github 上有一个很好的页面:https://help.github.com/articles/dealing-with-line-endings

简而言之,您可以使用文本属性来设置特定文件扩展名的行结束符。例如,将 sln 文件强制为 CRLF 需要在 .gitattributes 文件中添加以下行:

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf

关于git - git 存储库是否具有覆盖全局值的 core.autocrlf 自己的本地值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12340429/

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