I was wondering if there was a way to do an interactive rebase from one branch onto the current branch but not onto the head. Kind of like combination of
git rebase -i otherbranch and
git rebase -i HEAD~2.
What I want to do is be presented with an interactive rebase file where i can arrange not only the commits from the remote branch but also a range of commits on the current branch beginning from the head.
The scenario I have is:
- i have feature branch B1
- while waiting for code review I started a new feature by branching from B1. The new branch is B2
- code review finally happened and I had to fix something in B1
- changes are applied to B1 by way of an amend (not a new commit)
Now I need to update B2 with the revised commit from B1. I want the revised the commit to replace the original commit.
Simply rebasing B1 into B2 will result in the original and the revised commit appearing in B2's history (and there will probably be some nasty merge conflicts).
If I could get the B1 unique commits and a range of B2's commits in the interactive rebase prompt then i can tell git to discard the old version of the commit and use the new one from B1 in it's place all in one operation.
So it might look something like:
git rebase -i B1 HEAD~2
Currently I do this by branching B1 into
temp then cherry-picking the new commit from B2 onto it, erase B2 then move temp to B2. Which is fine I guess... but if i could do it as part of a rebase it would be nicer (i think).