Reputation: 23557
I have a set of branches like the following:
* 444ddd - somefeature3
/
* 333ccc - somefeature2
/
* 222bbb - somefeature1
/
------* 111aaa - master
If I were on a single branch (let's say somefeature3
without somefeature2
or somefeature1
existing), I could update all of my commits by doing git rebase -i 111aaa
. In other words, I could go from this:
* 444ddd - somefeature3
/
* 333ccc
/
* 222bbb
/
------* 111aaa - master
...to this:
* 444eee - somefeature3
/
* 333ddd
/
* 222ccc
/
------* 111aaa - master
In particular, commit 222bbb
was replaced with 222ccc
, 333ccc
was replaced with 333ddd
, and 444ddd
was replaced with 444eee
.
However, if I care about the branch pointers somefeature2
and somefeature1
, they won't get updated in this scenario. I would go from this:
* 444ddd - somefeature3
/
* 333ccc - somefeature2
/
* 222bbb - somefeature1
/
------* 111aaa - master
...to this:
* 444eee - somefeature3
/
* 333ddd * 333ccc - somefeature2
/ /
* 222ccc * 222bbb - somefeature1
/ /
------* --------------*
111aaa - master
What I want to have happen instead is for the final state to look like this, with the branch pointers somefeature2
and somefeature1
updated along with somefeature3
:
* 444eee - somefeature3
/
* 333ddd - somefeature2
/
* 222ccc - somefeature1
/
------* 111aaa - master
Is there any way to have Git automatically update the branch pointers for somefeature1
and somefeature2
as well as part of the git rebase -i
, producing this end state?
(meta: this is similar to this question, but it goes further by asking if it's possible to have Git do the appropriate foo automatically)
Upvotes: 2
Views: 343
Reputation: 60255
Closest I can get to easy is to use interactive rebase and add in exec git branch -f branchname
after the picks for those tips. If this turns in to a regular thing for you, you're in scripting territory, use your favorite editor to run git for-each-ref --points-at
on each line with a format that spits the updates.
Upvotes: 2