我特别需要git将大多数文件扩展名视为二进制文件,除了一些扩展名.
我想将所有文件扩展名视为二进制文件,.pdf .doc .xls等,除了.txt .rb .py等纯文本文件.
我已经尝试过如下配置.gitattributes来看看它是如何工作的:
# cat .gitattributes
* binary
*.txt text
Run Code Online (Sandbox Code Playgroud)
我想也许配置文件中的顺序很重要,但似乎没有.使用上述配置,所有文件仍被视为二进制文件.
有没有办法配置.gitattributes或git以任何其他方式将所有文件作为二进制处理,除了一些例外?
更新1:
我尝试了下面描述的.gitattributes.有用!
# cat .gitattributes
*.txt crlf diff
* binary
# git diff
diff --git a/file b/file
index d929b94..bee5cb1 100644
Binary files a/file and b/file differ
diff --git a/file.txt b/file.txt
index 632ae98..93d22b0 100644
--- a/file.txt
+++ b/file.txt
@@ -1 +1,3 @@
Hey this is a .txt file
+Adding another line
+A new line
Run Code Online (Sandbox Code Playgroud)
更新2:
我相信crlf和text是相同的,即.gitattributes的以下两个配置是相同的:
# cat .gitattributes
*.txt crlf diff
* binary
# …Run Code Online (Sandbox Code Playgroud) git ×1