Reputation: 10911
I have cygwin and msysgit on my computer. I am trying to clone a repository for a vim package with this command:
cd ~/.vim/bundle
git clone https://github.com/jelera/vim-javascript-syntax.git
However, when I run vim, it fails, reporting error E488: Trailing characters
. This appears to be cause by the line endings being CRLF
rather than just LF
, which is confirmed when I replace them.
Of course replacing them manually isn't what I want. I'd rather have git do it for me. However, as I am using my computer for developing on the Windows platform, I don't want to modify any global settings.
Is there a command line switch to have git clone a repo using LF
EOLs
only?
Upvotes: 21
Views: 5376
Reputation: 10911
Ok, so it turns out that a config key can be set at the command line using the -c
switch. That would change my command to:
cd ~/.vim/bundle
git clone -c core.autocrlf=false https://github.com/jelera/vim-javascript-syntax.git
From git clone help:
--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.
and git config help:
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 haveCRLF
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.
I've verified that this fixes the issue.
Upvotes: 34