So let's say we have a master branch and a feature branch.
(master) M1 -> M2 -> M3 -> M4
\
(feature) M2 -> F1
Now what I want to do is merge all the changes in F1 into commit M2 (not after M4). I know rebasing F1 to master or merging into master will add F1 after M4. However, I want to amend the M2 commit with changes from F1.
Here is what I have tried already: rebasing to edit M2, cherry-picking F1 into M2, soft-reset to M1, commit, then continue rebase. This more or less worked but if there are conflicts between M3 /M4 and F1, then the behavior was a little weird (can't explain because I didn't understand it fully).