【发布时间】:2020-08-23 14:09:51
【问题描述】:
我有一组如下分支:
* 444ddd - somefeature3
/
* 333ccc - somefeature2
/
* 222bbb - somefeature1
/
------* 111aaa - master
如果我在一个分支上(假设somefeature3 没有somefeature2 或somefeature1 存在),我可以通过执行git rebase -i 111aaa 来更新我的所有提交。换句话说,我可以从这个出发:
* 444ddd - somefeature3
/
* 333ccc
/
* 222bbb
/
------* 111aaa - master
...到这个:
* 444eee - somefeature3
/
* 333ddd
/
* 222ccc
/
------* 111aaa - master
特别是,提交222bbb 被替换为222ccc,333ccc 被替换为333ddd,444ddd 被替换为444eee。
但是,如果我关心分支指针 somefeature2 和 somefeature1,它们将不会在这种情况下得到更新。我会从这里开始:
* 444ddd - somefeature3
/
* 333ccc - somefeature2
/
* 222bbb - somefeature1
/
------* 111aaa - master
...到这个:
* 444eee - somefeature3
/
* 333ddd * 333ccc - somefeature2
/ /
* 222ccc * 222bbb - somefeature1
/ /
------* --------------*
111aaa - master
我希望最终状态看起来像这样,分支指针somefeature2 和somefeature1 与somefeature3 一起更新:
* 444eee - somefeature3
/
* 333ddd - somefeature2
/
* 222ccc - somefeature1
/
------* 111aaa - master
有什么方法可以让 Git 自动更新 somefeature1 和 somefeature2 的分支指针以及 git rebase -i 的一部分,从而产生这个结束状态?
(meta:这类似于this question,但它进一步询问是否可以让 Git 自动执行适当的 foo)
【问题讨论】:
-
请在你的 rebase 操作后向我们展示你想要的分支结构。
-
编辑了我的问题以包含更多图表和细节。
-
Git 确实需要一个“多分支”变基命令,针对这些情况。现在
git rebase -r存在,内部rebase 代码有足够的机制来实现正确的结果;它只需要一些 external 方法来指定要更新的正确名称集。
标签: git branch rebase feature-branch