【问题标题】:gitattributes and the binary optiongitattributes 和二进制选项
【发布时间】:2015-10-13 01:11:54
【问题描述】:

在 gitattributes 中,您可以指定特定文件类型应被视为二进制文件,例如

*.myExt binary

发件人:

http://git-scm.com/docs/gitattributes

这意味着不会应用任何行结束转换或将产生文本差异。

但是如果我仍然需要合并内容会怎样? git 会尝试合并它还是直接跳过 gitattributes 文件中列为binary 的所有文件类型?

不清楚: http://git-scm.com/docs/gitattributes

如果标记为 binary 的文件类型将被合并(意味着 git 将尝试进行合并/报告可能的冲突或直接跳过此类型的文件)。

【问题讨论】:

  • 合并的意思是......?

标签: git


【解决方案1】:

如果您将文件标记为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 转换,并从隐含-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(-)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-23
    • 2019-08-03
    • 2014-11-22
    • 1970-01-01
    • 2014-12-27
    • 2014-10-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多