简体   繁体   English

分支机构救援:Cherry-pick合并提交吗?

[英]Branch rescue: cherry-pick merge commits?

I need to rescue a feature branch which got some duplicated commits due to a rebase fail. 我需要抢救一个功能分支,由于重新设置失败,该分支获得了一些重复的提交。 Currently the only way to fix it is to cherry-pick all commits off this feature branch into master (see background below). 当前,解决此问题的唯一方法是将所有从该功能分支提交的内容樱桃挑选到master(请参见下面的背景)。

We started with the most recent state of master and then started cherry-picking our feature-branch commits. 我们从最新的master状态开始,然后开始挑选我们的功能分支提交。 However we sometimes merged master into our feature branch and I'm unsure if I also need to cherry-pick those merge commits. 但是,有时我们会将master合并到功能分支中,我不确定是否还需要挑选那些合并提交。 I think not, because I already resolved the conflicts when cherry-picking into the current master. 我认为不是,因为我已经解决了当初选择现任大师时的矛盾。 Is that correct? 那是对的吗?

PS: Background PS:背景

We discovered the duplicated commits too late and the feature branch already has 100 more commits on top. 我们发现重复的提交为时已晚,并且功能分支的顶部已经有100多个提交。 Due to our CI structure we can't just revert the duplicate commits. 由于我们的CI结构,我们不能只还原重复的提交。 Our first try at rescuing was to rebase and just ommit the duplicate commits. 我们进行抢救的第一个尝试是重新设置基础并只忽略重复的提交。 This does not work as it changes revision ids of some commits which are not part of our feature branch (we can't change revison ids of commits already in master!). 这不起作用,因为它更改了不在我们功能分支中的某些提交的修订ID(我们无法更改已在master中的提交的修订ID!)。 Therefore our current mode of rescue is to just cherry-pick all changes in this feature branch into master. 因此,我们当前的救援模式是将所有功能分支中的所有更改全部挑选到master中。

Maybe you should rebase your feature branch onto the latest master branch, fixing all weirdnesses instead? 也许您应该将功能分支重新建立到最新的master分支上,而不是解决所有怪异问题?

If not, then yes, you are right. 如果不是,那么是的,您是正确的。 When you do the same conflict resolution when cherry-picking the commits from the feature branch to master that you did when merging master into the feature branch, you should not need to pick the merge commits. 当您从特征分支向主分支中挑选提交时执行与在将母版合并到功能分支中时所做的相同的冲突解决方案时,您无需选择合并提交。 Actually if you do merge the merge commit, I'd exepect you end up with no changes as you should have solved the conflicts properly already. 实际上,如果您确实合并了合并提交,那么我希望您最终不会进行任何更改,因为您应该已经正确解决了冲突。 You cannot cherry-pick a merge commit anyway without giving the mainline with -m manually anyway. 无论如何,无论如何都必须手动给-m主线,否则就不能选择合并提交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM