父母改变时重新进行合并提交 [英] Rebase a merge commit when parents changed

查看:114
本文介绍了父母改变时重新进行合并提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  P1- 
\ $ b由于gerrit变更集取决于另外两个独立的变更集$ b P2 ---- C

gerrit将此表示为具有两个父项的合并提交。与普通的合并提交不同,它将包含与父代变更无关的非平凡变更。



父变更集在gerrit中更新,所以我们有提交P1'和P2',它们是P1和P2的修改版本,根据代码评论反馈进行修改。什么是最简单的生产C'的方式,这是与父母P1'和P2'的合并提交,并且包含与C相同的变更(相对于其父母)?

解决方案

到目前为止我所得到的最接近的结果是使用rebasing来创建一个具有正确父母和提交的提交,但没有原始提交的内容:

  git checkout C 
git rebase --preserve-merges --onto P1'P1
git rebase --preserve-merges --onto P2'P2

...然后手动应用C中的所有更改,如<$ c所示$ c> git show C 。有一种方法来转换 git show 的输出(a 组合差异)到一个正常的差异会使它有可能自动化 - 我已经问过,作为一个单独的问题:将组合差异转换为补丁


Given a gerrit changeset which depends on two other, independent changesets:

P1-
   \
P2----C

gerrit represents this as a merge commit with two parents. Unlike normal merge commits though, it will contain nontrivial changes that are not related at all to the changes in the parents.

The parent changesets are updated in gerrit, so we have commits P1' and P2', which are amended versions of P1 and P2, modified based on code review feedback. What is the easiest way of producing C' which is a merge commit with parents P1' and P2', and contains the same changes (relative to its parents) as C?

解决方案

The closest I have gotten so far is to use rebasing to create a commit with the right parents and commit, but without the contents of the original commit:

git checkout C
git rebase --preserve-merges --onto P1' P1
git rebase --preserve-merges --onto P2' P2

...then manually apply all the changes in C, as shown by git show C. Having a way to transform the output of git show (a combined diff) into a normal diff would make it possible to automate this - I have asked that as a separate question: Transform a combined diff into a patch

这篇关于父母改变时重新进行合并提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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