Reputation: 1454
I can't seem to figure this Git scenario out after reading the man page and searching some of the questions here, so I hope some of you can help me out.
Here's the situation. I've got two branches, let's call them master
and experimental
, with the commit graph looking like this:
A---B---C---D master
\
E---F---G---H experimental
and I want to end up here:
A---B---C---D---F---H master
\
E---F---G---H experimental
I could achieve this by successively cherry-picking all relevant commits from experimental
, but I'd like to use git rebase -i
to get a list of all commits and select the relevant ones. Is this possible?
Upvotes: 1
Views: 121
Reputation: 1323543
It is possible, but first, mark your experimental
branch with a new 'tmp
' branch:
git checkout experimental
git checkout -b tmp
Then do your rebase:
git rebase -i master
And drop all the commits you don't want.
(master)
|
A---B---C---D---F'---H' tmp
\
E---F---G---H experimental
Finally, merge master
to tmp
git checkout -B master # reset master to tmp
git branch -d tmp
Since a rebase moves a branch, and since it is master
that has to change, jthill points out in the comments the shortest solution:
git checkout -B master experimental
git rebase -i master@{1}
See more on HEAD@{1}
at:
Upvotes: 3