27

In my project, the build result is a ZIP archive containing a .jar, several HTML files, a bash script, and a Windows .cmd file.
Now, I would like to add the Windows .cmd file to git, keeping the Windows.style CRLF line format. The rest of the project is Linux-style LF.

I have found several questions about CRLF in git, but all of the answers were about

[core]
     autocrlf = true

but that does not match my needs, as I do not want to have the whole project as CRLF, only this one Windows .cmd file (maybe very few more in future).

So, how can I tell git to keep CRLF only for handpicked files ?

Markus N.
  • 491
  • 4
  • 7
  • 2
    possible duplicate of [how to make git not change line endings for one particular file?](http://stackoverflow.com/questions/10357436/how-to-make-git-not-change-line-endings-for-one-particular-file) – Michael Apr 16 '15 at 15:45

1 Answers1

49

You can use .gitattributes, an entry such as:

*.cmd eol=crlf

This will ensure that the file is checked out with windows line endings even in clones that would normally use unix line endings,

CB Bailey
  • 755,051
  • 104
  • 632
  • 656