I have a long linear git history. I want to rebase some commits so it is as if I created a feature branch and merged it back to master using git merge --no-ff master
.
Current
A -> B -> C -> D -> E -> F
master
Desired
master
A -> B -> E -> F
\ /
C -> D
feature
I thought to do something like
git checkout D
git checkout -b feature
git rebase B
git merge --no-ff E
But D
already has B
in its history, so this doesn't do anything. I know how to rebase E
off of B
(Split a git branch into two branches?), but here, the desired version of E
has two parents.
Some additional details is that originally my project was structured like Desired
, and E
is really a merge commit. I somehow then linearized my history using git rebase
to remove some unwanted files from old commits.