16

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?

2
  • Can someone help me improve my Q & A? I don't understand why I got downvoted.
    – Adrian
    Jun 21, 2018 at 17:36
  • Looks like it was just a driveby downvoting. I don't see anything wrong. Only mods were just some minor formatting changes.
    – Adrian
    Jun 21, 2018 at 17:55

1 Answer 1

26

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 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.

I've verified that this fixes the issue.

3
  • Don't know why this got downvoted, it's the right answer.
    – torek
    Jun 21, 2018 at 18:30
  • @torek, yeah. Weird eh? And I don't know why the question was either. It seems like a reasonable question.
    – Adrian
    Jun 21, 2018 at 22:30
  • Exactly what I was looking for.
    – Zolbayar
    Oct 19, 2020 at 5:12

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.