Git变基并自动更新分支指针?

问题描述 投票:0回答:1

我有一组类似以下的分支:

            * 444ddd - somefeature3
           /
          * 333ccc - somefeature2
         /
        * 222bbb - somefeature1
       /
------* 111aaa - master

[如果我在单个分支上(假设somefeature3不存在somefeature2somefeature1),我可以通过执行git rebase -i 111aaa更新所有提交。换句话说,我可以从这里开始:

            * 444ddd - somefeature3
           /
          * 333ccc
         /
        * 222bbb
       /
------* 111aaa - master

...到此:

            * 444eee - somefeature3
           /
          * 333ddd
         /
        * 222ccc
       /
------* 111aaa - master

特别是,将提交222bbb替换为222ccc333ccc替换为333ddd,并且444ddd替换为444eee

但是,如果我关心分支指针somefeature2somefeature1,在这种情况下将不会更新它们。我会从这里出发:

            * 444ddd - somefeature3
           /
          * 333ccc - somefeature2
         /
        * 222bbb - somefeature1
       /
------* 111aaa - master

...到此:

            * 444eee - somefeature3
           /
          * 333ddd        * 333ccc - somefeature2
         /               /
        * 222ccc        * 222bbb - somefeature1
       /               /
------* --------------*
       111aaa - master

我想发生的是使最终状态看起来像这样,分支指针somefeature2somefeature1somefeature3一起更新:

            * 444eee - somefeature3
           /
          * 333ddd - somefeature2
         /
        * 222ccc - somefeature1
       /
------* 111aaa - master

有没有办法让Git自动更新somefeature1somefeature2以及git rebase -i的一部分的分支指针,从而产生此结束状态?

((元:与this question类似,但是它进一步询问是否可以让Git自动执行适当的foo)]

git branch rebase feature-branch
1个回答
0
投票

最近,我可以轻松解决的是使用交互式变基,并在选择这些技巧后添加exec git branch -f branchname。如果这对您来说很正常,那么您就在编写脚本的领域,请使用您喜欢的编辑器在每一行上运行git for-each-ref --points-at,其格式会吐出更新。

© www.soinside.com 2019 - 2024. All rights reserved.