2

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)

3
  • Please show us the branch structure you want after your rebase operation. Commented May 8, 2020 at 4:34
  • Edited my question to include more diagrams and detail. Commented May 8, 2020 at 5:15
  • Git really needs a "multi-branch" rebase command, aimed at these kinds of situations. Now that git rebase -r exists, the internal rebase code has enough machinery to achieve the correct result; it just needs some external way to specify the right set of names to be updated. Commented May 8, 2020 at 16:18

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.