1

I need to add a file to a git repository, and I need the correct type of line ending.

In perforce, I would just use "-t binary" to force the file to binary, but I don't know how to set the file to binary in GIT.
The repository is rather large, so I don't want to make a global change.
The new file is .html, and I already have thousands of .html files whose type I don't want to change.
I don't have a choice about the name for the new file either.

So, how do I force just one file to binary in git without making global changes?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Matthias Wandel
  • 6,383
  • 10
  • 33
  • 31

1 Answers1

2

you can record your file in a .gitattributes file (that you can put in the same directory as your file):

yourFile.html binary

It is the same as:

yourFile.html -crlf -diff
yourFile.html -text -diff

This is slightly different than core.eol directive (in that same .gitattributes file):

yourFile.html eol=lf

That would autocorrect end of lines on git checkout.
You don't need that in your case: binary is enough.

More in "Dealing with line endings".

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250