在gitattributes中,您可以指定特定文件类型应被视为二进制文件,例如
*.myExt binary
自:
http://git-scm.com/docs/gitattributes
这意味着不会应用行结束转换或将生成文本差异。
但是如果我还需要合并内容会怎么样? git会尝试合并它,还是只是跳过gitattributes文件中列为binary
的所有文件类型?
从以下方面不清楚: http://git-scm.com/docs/gitattributes
如果标记为 binary 的文件类型将被合并(意味着git将尝试进行合并/报告可能的冲突,或者只是跳过此类型的文件)。
答案 0 :(得分:2)
如果您将文件标记为binary
,则该文件无法自动启用。如果两个分支都更改了文件,那么git将拒绝执行合并,并将文件标记为冲突:
% cat .gitattributes
foo.txt binary
% git merge branch
warning: Cannot merge binary files: foo.txt (HEAD vs. branch)
Auto-merging foo.txt
CONFLICT (content): Merge conflict in foo.txt
Automatic merge failed; fix conflicts and then commit the result.
但是,如果您希望允许文件自动启用,但仍保留binary
属性的其他效果 - 即从隐含的-text
属性中删除CR / LF转换,并删除差异& #39;来自隐含-diff
属性的功能,然后您可以设置 merge
属性:
% echo 'foo.txt binary merge' > .gitattributes
% cat .gitattributes
foo.txt binary merge
% git merge branch
Auto-merging foo.txt
Merge made by the 'recursive' strategy.
foo.txt | Bin 112 -> 112 bytes
1 file changed, 0 insertions(+), 0 deletions(-)