gpt4 book ai didi

git - 尝试克隆存储库但行尾错误

转载 作者:太空狗 更新时间:2023-10-29 13:36:59 32 4
gpt4 key购买 nike

我的电脑上有 cygwin 和 msysgit。我正在尝试使用此命令为 vim 包克隆存储库:

cd ~/.vim/bundle
git clone https://github.com/jelera/vim-javascript-syntax.git

但是,当我运行vim时,它失败了,报错E488: Trailing characters。这似乎是由于行结尾是 CRLF 而不仅仅是 LF,当我替换它们时确认了这一点。

当然,手动替换它们不是我想要的。我宁愿让 git 为我做这件事。但是,由于我是在Windows平台上使用我的电脑进行开发,所以我不想修改任何全局设置。

是否有命令行开关让 git 克隆一个 repo 仅使用 LF EOLs

最佳答案

好的,事实证明可以使用 -c 开关在命令行中设置配置键。这会将我的命令更改为:

cd ~/.vim/bundle
git clone -c core.autocrlf=false https://github.com/jelera/vim-javascript-syntax.git

来自 git clone帮助:

--config <key>=<value>
-c <key>=<value>

    Set a configuration variable in the newly-created repository; this takes effect immediately after the repository is initialized, but before the remote history is fetched or any files checked out. The key is in the same format as expected by git-config[1] (e.g., core.eol=true). If multiple values are given for the same key, each value will be written to the config file. This makes it safe, for example, to add additional fetch refspecs to the origin remote.

git config帮助:

core.autocrlf

    Setting this variable to "true" is the same as setting the text attribute to "auto" on all files and core.eol to "crlf". Set to true if you want to have CRLF line endings in your working directory and the repository has LF line endings. This variable can be set to input, in which case no output conversion is performed.

我已经确认这可以解决问题。

关于git - 尝试克隆存储库但行尾错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50974005/

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