当您使用 Linux 和 Windows 时,最好的 git config 设置是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6081607/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the best git config set up when you are using Linux and Windows?
提问by shin
I am a bit confused with core.eol, core.autocrlf, core.safecrlf for git config.
我对 git config 的 core.eol、core.autocrlf、core.safecrlf 有点困惑。
http://git-scm.com/docs/git-config
http://git-scm.com/docs/git-config
I am using Ubuntu and Widows.
我正在使用 Ubuntu 和寡妇。
I had ^M, and other issues before.
我之前有 ^M 和其他问题。
Could anyone suggest the best git config setups for this problem?
任何人都可以为这个问题建议最好的 git 配置设置吗?
Thanks in advance.
提前致谢。
采纳答案by VonC
As detailled in Git on Windows (msysgit) - Unix or DOS line termination, I would use:
正如Windows (msysgit) 上的 Git - Unix 或 DOS 行终止中详述的那样,我将使用:
git config --system core.autocrlf false
That would avoid any automatic eol transformation (See "Git on Windows: What do the crlf settings mean?" for the exact meaning of this option value).
这将避免任何自动 eol 转换(有关此选项值的确切含义,请参阅“ Windows 上的 Git:crlf 设置意味着什么?”)。
You can leave it to true, as explained in git replacing LF with CRLF, but I prefer setting core.eol
+ some gitattribute
files in order to fine tune some of the files I want eol changes on.
See this answerfor more details.
您可以将其保留为 true,如git 用 CRLF 替换 LF 中所述,但我更喜欢设置core.eol
+ 一些gitattribute
文件,以便微调一些我想要 eol 更改的文件。
有关更多详细信息,请参阅此答案。