Lets say I have a branch based on master which ends with merge commit:
--A---C<master]---D---E---F<my-feature]
\ /
B
Adding a commit X
between D
and E
with interactive rebase is simple - I run
git rebase -i master
, set commit D
operation to edit
, rebase stops after rebasing D
. I just create the new commit at that moment and then continue rebase. The branch now looks like
...C<master]---D---X---E'---F'<my_freature]
.
Now I want to add a commit between C
and D
.
Desired result:
C<master]---X---D'---E'---F'<my_freature]
I tried
git rebase -i master~
where I wanted to set the merge commit C
to edit
, but interactive rebase somehow ignores the merge commit C
and offers me only chain A--B--D--E
, so the rebase results in loss of merge commit C
.
Is there a simple way prepend a commit to a branch with interactive rebase like this?
Please note that I can figure a bit more complex solution like creating new branch tmp
on master
, committing X
to it then rebase my-feature
onto tmp
, I'm just curious if there is a simple and straightforward way with interactive rebase.