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?
Whereas Windows follows the original convention of a carriage return plus a line feed ( CRLF ) for line endings, operating systems like Linux and Mac use only the line feed ( LF ) character. The history of these two control characters dates back to the era of the typewriter.
You can set the mode to use by adding an additional parameter of true or false to the above command line. If core. autocrlf is set to true, that means that any time you add a file to the Git repository that Git thinks is a text file, it will turn all CRLF line endings to just LF before it stores it in the commit.
While Git normally leaves file contents alone, it can be configured to normalize line endings to LF in the repository and, optionally, to convert them to CRLF when files are checked out. Here is an example that will make Git normalize . txt, .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With