Force just one file as binary in GIT

◇◆丶佛笑我妖孽 提交于 2020-01-02 23:18:29

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/17883475/force-just-one-file-as-binary-in-git

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!