混帐合并,保持两个 [英] git merge, keep both

查看:95
本文介绍了混帐合并,保持两个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了合并,我使用它来保存我的

  git merge -X我们的foo 

,并用于保留他们

  git merge -X他们foo 

然而,在我的最新合并中,它最好保持双方。 Git是否有这样的策略,以避免手动编辑文件? 解决方案

解决这些冲突。



然而,如果你真的想要这样的冲突:

 <<<<我们的
Foo
=========
Bar
>>>>他们的

解析为

  Foo 
Bar

然后你可以配置'merge driver 。从 gitattribute 手册页:


union

对文本文件运行3-way文件级别合并,但从
这两个版本中取出留下冲突标记。这往往是
在结果文件中以随机顺序留下添加的行,并且
用户应该验证结果。如果您不了解
的含义,请不要使用它。


添加一行到.gitattributes以使用它:

  *。whatever merge = union 


For merging I use this to "keep mine"

git merge -X ours foo

and this for "keep theirs"

git merge -X theirs foo

However on my latest merge it looks best to keep both sides. Does Git have a "strategy" for this, to avoid manually editing the file?

解决方案

There is no 'merge strategy' for resolving these conflicts.

However, if you truly want a conflict like:

<<<< ours
Foo
=========
Bar 
>>>> theirs

to resolve to

Foo
Bar

then you can configure the 'merge driver'. From the gitattributes man page:

union

Run 3-way file level merge for text files, but take lines from both versions, instead of leaving conflict markers. This tends to leave the added lines in the resulting file in random order and the user should verify the result. Do not use this if you do not understand the implications.

Add a line to .gitattributes to use this:

*.whatever merge=union

这篇关于混帐合并,保持两个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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