在冲突时始终使用合并分支中的版本 [英] Always use version from merged branch on conflicts
问题描述
那么,是否有可能告诉git始终使用合并分支中的版本以避免事先合并冲突?在这种情况下,我手动修复了冲突,但始终从合并分支中选择版本,这样可以为我节省一些繁琐的工作。
假设特性$ c,您可以使用以下命令在git中完成此操作
git merge -s递归-X他们的特性
code>
这表示使用递归合并策略,但使用theirs选项。这意味着当发生冲突时,它将通过从功能分支获取人体的版本而不是您当前的分支来自动解决。 (请注意,这与他们的合并策略完全不同,现在已从git中删除了它们。)
此功能是在git v1.7.0中引入的。
Currently I am working in a feature branch that will soon be merged back into master. I recently tried just that and had some merge conflicts, which I had to fix manually.
So, is it possible to tell git to always use the version from the merged branch in order to avoid merge conflicts beforehand? In this case I fixed the conflicts manually but always chose the version from the merged branch, so this would save me some tedious work.
You can do exactly this in git with the following command, assuming that feature
is the name of your feature branch:
git merge -s recursive -X theirs feature
This says to use the "recursive" merge strategy, but with the "theirs" option. This means that when there is a conflict, it will be automatically resolved by taking the version of the hunk from the feature branch, not your current branch. (Note that this is completely different from the "theirs" merge strategy, which has now been removed from git.)
This feature was introduced in git v1.7.0.
这篇关于在冲突时始终使用合并分支中的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!