有没有“他们的”版本的“git merge -s我们的”? [英] Is there a "theirs" version of "git merge -s ours"?

查看:218
本文介绍了有没有“他们的”版本的“git merge -s我们的”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用 git merge 合并主题分支B到A时,我遇到了一些冲突。我知道所有的冲突都可以使用B中的版本解决。



我知道 git merge -s our 。但是我想要的是像 git merge -s他们的之类的东西。



为什么不存在?在与现有的 git 命令冲突合并之后,我如何获得相同的结果? ( git checkout B中的每个未合并文件)



更新:仅丢弃分支A的解决方案 (合并提交点指向B版本的树)并不是我正在寻找的。

解决方案

添加 -X 选项设置为他们的。例如:

  git checkout branchA 
git merge -X他们的分支B



所有的东西都会以合意的方式合并。



问题是如果从分支B中删除文件。如果除git以外的东西进行删除,它们会显示为冲突。



修复很简单。只需运行 git rm 即可删除任何文件的名称:

  git rm {DELETED-FILE-NAME} 

之后, - X他们的应该按预期工作。

当然,使用 git rm 命令执行实际的删除操作可以防止冲突发生在第一位。






注意:还存在一个更长的表单选项。要使用它,请替换:

  -X他们的

与:

   -  strategy-option =他们的


When merging topic branch "B" into "A" using git merge, I get some conflicts. I know all the conflicts can be solved using the version in "B".

I am aware of git merge -s ours. But what I want is something like git merge -s theirs.

Why doesn't it exist? How can I achieve the same result after the conflicting merge with existing git commands? (git checkout every unmerged file from B)

UPDATE: The "solution" of just discarding anything from branch A (the merge commit point to B version of the tree) is not what I am looking for.

解决方案

Add the -X option to theirs. For example:

git checkout branchA
git merge -X theirs branchB

Everything will merge in the desired way.

The only thing I've seen cause problems is if files were deleted from branchB. They show up as conflicts if something other than git did the removal.

The fix is easy. Just run git rm with the name of any files that were deleted:

git rm {DELETED-FILE-NAME}

After that, the -X theirs should work as expected.

Of course, doing the actual removal with the git rm command will prevent the conflict from happening in the first place.


Note: A longer form option also exists. To use it, replace:

-X theirs

with:

--strategy-option=theirs

这篇关于有没有“他们的”版本的“git merge -s我们的”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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