I've researched this on SO and other documentation. I've tried rebasing, merging, cherry-picking, and detached heads.
After literally 6 hours of trying to do this, it's time to ask the question!
Here's what I'm starting with:
A-B-C-D-E-F-G master
Here's what I want to change it to:
A-B F-G master
\ /
C-D-E dev
The closest I've come is:
A-B C-D-E-F-G-H Main
\ /
C-D-E dev
\
F-G master
I had to add another branch name and a dummy commit to get the branching to work at all.
But this is worse than no change.
Please help!
UPDATE AFTER REPLIES
Thanks for the replies.
Yes, my "what I want" was not very clear. Hopefully this clarifies it:
A-B - F-G master
\ /
C-D-E dev
In other words, "master" at F is the result of B plus branch "dev" merged into it.
STILL NOT WORKING
Thanks @frasertweedale for the attempted answer.
I've followed your instructions carefully and here's what I end up with:
A-B - "merge branch 'dev'"-G master
\ /
C-D-E dev
\
F-G-"merge branch 'dev'"-F-G
I'm glad this is hard: having now spent 7 hours on this I don't feel as bad!
FINAL RESULT As @frasertweedale said, this is exactly what I wanted except for the dangling commits.
So, I simply need to get rid of the dangles.
For clarity, I've redrawn below:
A-B - "merge branch 'dev'"-G2 master
\ /
C-D-E dev
\
F1-G1-"merge branch 'dev'"-F2-G2
And this command does the cleanup:
git rebase -p --onto F1^ F1
Result:
A-B - "merge branch 'dev'"-G2 master
\ /
C-D-E dev
"merge branch 'dev'" contains the original F commit, and can, of course, be re-commented that way.