告诉git不要合并二进制文件,但要选择 [英] Tell git not to merge binary files but to choose

查看:239
本文介绍了告诉git不要合并二进制文件,但要选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当二进制文件,swfs,jars和flvs在本地发生更改时,我尝试引入更改,git尝试合并它们并报告冲突。 然后,我分支到一个临时分支,并提交本地更改的二进制文件,并将其合并回来后,递归他们的策略。 - 太多的工作。

有没有办法告诉git,而不是试图合并二进制文件并询问我使用哪一个版本。

解决方案

您可以在 .gitattributes 文件中设置合并驱动器(仅适用于给定的子树,只适用于某些文件类型)



请参阅这个问题

 #选择合并的名称,例如-mo-files / 2408931#2408931> this one )用于所有jar文件的驱动程序
echo * .jar merge = keepTheir> dirWithJarFiles\.gitattributes

在Git repo的配置中声明您的合并驱动程序:



pre $ g $ git config merge.keepTheir.name在合并期间始终保持它们
git config merge.keepTheir.driverkeepTheir.sh% O%A%B



<$
git config merge.keepMine.driverkeepMine.sh%O%A%B
$ g $ git config merge.keepMine.name [合并keepMine]
name =在合并期间始终保留我的
driver = keepMine.sh%O%A%B

我给出的示例并不要求您做出选择,但在合并时始终保留我的(或您的)版本。

但您可以调整由此合并驱动程序执行的脚本来询问您一个问题,然后将您的选择应用于所有合并。


When the binary files, swfs, jars and flvs are changed locally, and I try to pull in changes, git tries to merge them and reports conflict.

And then, I branch to a temporary branch, and commit the local changed binary files, and merge them back after the pull with recursive theirs strategy. -- Too much work.

Is there a way to tell git, not to attempt merging binary files and ask me which one of these versions to use.

解决方案

You could set up a merge drive in a .gitattributes file (only for a given subtree, only for some file types)

See this question for instance (or this one).

# choose the name of the merge driver to be use for all jar files
echo *.jar merge=keepTheir > dirWithJarFiles\.gitattributes

Declare your merge driver in the config of the Git repo:

git config merge.keepTheir.name "always keep their during merge"
git config merge.keepTheir.driver "keepTheir.sh %O %A %B"

or

git config merge.keepMine.name "always keep mine during merge"
git config merge.keepMine.driver "keepMine.sh %O %A %B"
[merge "keepMine"]
        name = always keep mine during merge
        driver = keepMine.sh %O %A %B

The example I give don't ask you for a choice but will always keep "mine" (or "yours") version when merging.
But you could adapt the script executed by this merge driver to ask you a question, and then apply your choice to all merges.

这篇关于告诉git不要合并二进制文件,但要选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆