Reputation: 1038
If I have the following git branches
master: A - B - C - DE
\
topic: \- D - E - F - G
Is there any way to merge commit F and G to master?
The reason I want to do this is that I've already done a pull request from topic to master before I made commit F
and commit G
to merge D
and E
to after C
. I did a squash and merge so now DE
contains the merge of D
and E
. Now I need merge only F
and G
to master.
Upvotes: 2
Views: 492
Reputation: 30156
You can do:
git rebase --onto master E topic
You are asking git to rebase topic branch on top of master discarding revisions up to E (so, basically asking to carry over F and G only).
Results:
master: A - B - C - DE
\
topic: F' - G'
Then you could merge into master
git checkout master
git merge topic
Or have the branch move instead:
git branch -f master topic
Alternatively, you could cherry-pick into master:
git checkout master
git cherry-pick topic~2..topic # bring over the last 2 revisions from topic into master
Upvotes: 2