Git Cherry-Pick将合并冲突 [英] Git cherry-pick will case merge conflict

查看:162
本文介绍了Git Cherry-Pick将合并冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我有两个分支机构:

Currently I got two branches:

主控

beta_001

beta_001有时是在母版中检出的.为了使beta_001能够更新到master版本,推送到master版本的提交也将被挑选到beta_001版本.在beta_001合并回主服务器之前,一切正常.

beta_001 is checked out from master sometimes ago. To make beta_001 update to date to master, commits pushed in master will also be cherry-picked to beta_001. All things worked fine until the day beta_001 was merged back to master.

很多两者都已修改的冲突像这样:

++<<<<<<< HEAD
+     <permission
+         android:name="com.xxx.permission.REDIRECT_MESSAGE"
+         android:protectionLevel="normal"/>
+     <permission
++=======
 +    <permission
 +        android:name="com.xxx.permission.REDIRECT_MESSAGE"
 +        android:protectionLevel="normal"/>
 +    <permission
++>>>>>>> origen/beta_001

或此

++<<<<<<< HEAD
++=======
+ 
+     <string name="xxx">xxxx</string>
++>>>>>>> origen/beta_001

我猜这是由于选择樱桃而导致提交ID不同的一种情况,那么如何防止这种情况发生呢?

I guess this is the case one change with difference commit ids due to cherry-pick, so how to prevent this?

推荐答案

Cherry Pick将始终为在新分支中选择的每个提交创建一个新的ID,并且当我们尝试合并到这些分支是樱桃的分支时,这肯定会显示冲突.摘自.

Cherry Pick will always create a new id for every commit picked in the new branch and this will definitely show conflicts when we try merging to the branch the commits were cherry picked from.

如果您要遵循当前的分支模型,则应将master合并到beta_001 分支中,以从具有相同提交ID的master获取所有提交.这样会添加合并提交,但可以避免您提到的冲突.

If you want to follow your current branching model, you should merge master into beta_001 branch to get all the commit from the master with the same commit id. This will add a merge commit but avoid the conflicts you mentioned.

或者,您可以将分支模型更改为GitFlow,以实现更好的分支管理. https://datasift.github.io/gitflow/IntroducingGitFlow.html

Alternatively, you can change your branching model to GitFlow for better branch management. https://datasift.github.io/gitflow/IntroducingGitFlow.html

这篇关于Git Cherry-Pick将合并冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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