在冲突时始终使用合并分支中的版本 [英] Always use version from merged branch on conflicts

查看:175
本文介绍了在冲突时始终使用合并分支中的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在一个功能分支中工作,这个功能分支很快就会被合并回主。我最近尝试过这样做,并且有一些合并冲突,我必须手动修复。

那么,是否有可能告诉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屋!

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