Git mark file as binary to avoid line separator conversion

左心房为你撑大大i 提交于 2019-11-30 18:23:44

Write this in .gitattributes (in the file’s directory or higher up):

myfile.bin -text

See the manual for more explanation.

Marking files as binary

Git usually guesses correctly whether a blob contains text or binary data by examining the beginning of the contents. However, sometimes you may want to override its decision, either because a blob contains binary data later in the file, or because the content, while technically composed of text characters, is opaque to a human reader. For example, many postscript files contain only ascii characters, but produce noisy and meaningless diffs.

The simplest way to mark a file as binary is to unset the diff attribute in the .gitattributes file:

*.ps -diff

This will cause git to generate Binary files differ (or a binary patch, if binary patches are enabled) instead of a regular diff.

In summary: specify -diff in .gitattributes.

While -text in .gitattributes did not worked,

myfile.bin binary

did.

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