此问题在此处已有答案:
How to determine if Git handles a file as binary or as text?(9个回答)
13天前关闭
我知道如何使用gitattributes强制Git将JPEG文件视为二进制文件,但实际上Git的默认二进制文件列表是什么?或者有任何二进制文件吗?我在我的系统上发现了似乎是系统范围的gitattributes文件,这是它的内容:
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
字符串
这是否意味着默认情况下图像不被视为二进制文件?
编辑:理论上也可能涉及一些“猜测”算法,但我还没有找到任何细节。
1条答案
按热度按时间pb3skfrl1#
git中没有默认的二进制文件列表。
这里有一个简单的算法:
如果前8000个字节中的任何一个包含NULL字符,则将其视为二进制。
你可以在这里阅读到最新的git稳定版本(2.43)的确切代码。
我能想到的最短的证明是:
字符串