vagrant w / windows作为主机,文件不会在vm上由于crlf而运行 [英] Vagrant w/ windows as host, files don´t run on vm due to crlf
问题描述
我想将vagrant文件本身提交到回购站,所以步骤将会是,在Windows中克隆回购,并且已经准备好并运行了。
问题在于,由于repo是在Windows中克隆的,因此所有文件都有crlf。当从vagrant ssh执行这些操作时,会抛出错误
如何使用windows作为主机和Linux作为guest虚拟机共存于一个流氓中,所以使用Windows的队友仍然可以编辑文件安全并提交它们?
提前致谢
I不建议将 core.autocrlf
设置为' false
'之外的任何内容:
git config --global core.autocrlf false
它是一个存储库范围设置,它将应用于所有文件,包括二进制文件。正如我在尝试提交Git文件但得到:致命:LF将被CRLF替换为<某些文件在repo>
中,它可能会破坏这些文件。
如果 / strong>,您需要确保其中使用的EOL,如 .gitattributes
文件,其中声明 core.eol
指令。
要控制工作目录中使用的行结束风格,请对单个文件使用
eol
属性,并使用core.eol
所有文本文件的配置变量。
#声明在结帐时始终具有CRLF行结尾的文件。
* .css text eol = lf
* .html text eol = lf
* .js text eol = lf
(参见 codewall示例,通过 Scott Grogan( ninjascribble
))
I´m trying to set up vagrant with windows as host and ubuntu as guest.
I want to commint vagrant file itself to the repo so the steps would be, clone repo in windows, vagrant up and have the env ready and running.
The problem is, since the repo is cloned in windows, all the files have crlf. When these are executed from vagrant ssh, throws error
How can a repo coexist in vagrant with windows as host and linux as guest, so my teammates that use windows can still edit files safely and commit them?
thanks in advance
I would no recommend core.autocrlf
to be set to anything else than 'false
':
git config --global core.autocrlf false
It is a repository-wide setting, which will apply to all files, including binary ones. As I explain in "Trying to commit Git files but getting: fatal: LF would be replaced by CRLF in <some file in repo>
", it can corrupt those.
If, for a certain type of files, you need to make sure of the EOL used in them, se a .gitattributes
file in which you declare a core.eol
directive.
To control what line ending style is used in the working directory, use the
eol
attribute for a single file and thecore.eol
configuration variable for all text files.
# Declare files that will always have CRLF line endings on checkout.
*.css text eol=lf
*.html text eol=lf
*.js text eol=lf
(see this codewall example, by Scott Grogan (ninjascribble
))
这篇关于vagrant w / windows作为主机,文件不会在vm上由于crlf而运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!