Git 合并并解决与当前分支的任何冲突
所以我有我的主分支,以及分支“bob”。
我对两者都做了很多更改,现在我想将 master 合并到 bob 中以使他保持更新。唯一的问题是,如果发生冲突,我希望它自动解决给 bob。
我被推荐如下:
git checkout bob
git merge master -s ours
这不起作用,因为我什至没有从 master 那里得到不冲突的更改。
请帮忙!
So I have my master branch, along with branch 'bob'.
I've made many changes in both and now I want merge master into bob to keep him updated. The only thing is, if there is a conflict I want it to automatically resolve to bob.
I've been recommended the following:
git checkout bob
git merge master -s ours
This does not work because I don't even get the changes from master that don't conflict.
please help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您需要合并从master到bob的所有更改:
问题“我如何告诉 git 始终选择本地版本来进行特定文件上的冲突合并?”解释了如何使用合并驱动程序来做到这一点。
一旦合并完成,一个简单的操作就是:
允许 master 的 HEAD 快进到 bob 的 HEAD。师父将从鲍勃的内容开始继续。
First, you need to merge all changes from master to bob:
The question "How do I tell git to always select my local version for conflicted merges on a specific file?" explains how to do that, with a merge driver.
Once the merge has been done, a simple:
allows for the HEAD of master to fast-forward to the one of bob. Master will go on from there from the content of bob.
我看到了与我们的合并策略的差距。如果集成您自己的合并驱动程序太多,并且如果您喜欢 Emacs,请考虑使用 ediff 作为您的“合并工具”。您可以告诉它“更喜欢”您在冲突中的贡献。除了仅关注冲突的更改之外,您还可以在提交之前查看合并结果,以确保仅采用您的贡献仍然会产生一致的文件。
不幸的是,ediff 尚未被集成为受支持的合并工具。 2007 年 6 月 git 邮件列表上的这个帖子描述了一些的整合问题。 这是另一个。
Git 确实附带了对另一种 Emacs 合并模式 emerge 的内置支持,但我更喜欢 ediff。
I see the gap with the ours merge strategy. If integrating your own merge driver is too much, and if you like Emacs, consider using ediff as your "merge tool". You can tell it to "prefer" your contributions in conflicts. That in addition to having it focus only on conflicting changes allows you to review the merge result before committing, just to make sure that taking only your contributions still result in a coherent file.
Unfortunately, ediff has yet to be integrated as a supported merge tool. This thread on the git mailing list from June 2007 describes some of the integration problems. Here's another.
Git does ship with built-in support for emerge, another Emacs merging mode, but I far prefer ediff.