我有一组类似以下的分支:
* 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
的一部分的分支指针,从而产生此结束状态?
((元:与this question类似,但是它进一步询问是否可以让Git自动执行适当的foo)]
最近,我可以轻松解决的是使用交互式变基,并在选择这些技巧后添加exec git branch -f branchname
。如果这对您来说很正常,那么您就在编写脚本的领域,请使用您喜欢的编辑器在每一行上运行git for-each-ref --points-at
,其格式会吐出更新。