我特別需要git把大多數文件擴展名當作二進制文件,除了一些擴展名。git的.gitattributes可以將所有文件視爲二進制文件,只有少數例外情況?
我願意把所有的文件擴展名是二進制,.PDF的.doc .xls的等等,除了純文本文件,如.txt .RB的.py等
我試過配置.gitattributes像下面來看看如何這可能工作:
# cat .gitattributes
* binary
*.txt text
我想也許在配置文件將此事的順序,但不會出現。通過上述配置,所有文件仍然被視爲二進制文件。
有沒有一種方法來配置.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
更新2:
我相信CRLF和文字都是一樣的,即兩個下方配置了.gitattributes是相同的:
# cat .gitattributes
*.txt crlf diff
* binary
# cat .gitattributes
*.txt text diff
* binary
「屬性設置或取消設置後,如果不能被隨後的規則更改。」非常有用的信息!謝謝。 – caleban 2010-11-24 20:23:16
@caleban:是的,`gitattribute`手冊頁的「EXAMPLE」部分(http://www.kernel.org/pub/software/scm/git/docs/gitattributes.html#_example)給出了一個很好的例子該規則。 – VonC 2010-11-24 20:32:01