I have three branches A, B and C. B is regularly merged into C.
o---o---o A
开发者_如何学Go /
--------o---o---o---o---o---o B
\ \ \ \
o---o---o---o---o---o C
Now I want to merge the changes I did in C, but without the merges from B, on top of A. What is the easiest way to do this in git?
Use the git rebase.
First, rebase your C on top of B:
git checkout C
git checkout -b rebasedC #Let's do a new branch for it also, just in case
git rebase B
it will place all C commits on to of B. Now we want transplant branch rebasedC from B to A:
git rebase --onto A B rebasedC
So, now you have your C-commits on top of A in the rebasedC branch. Now you can fast-forward your A to it:
git checkout A
git merge rebasedC
git branch -d rebasedC# I don't think you would need it.
That's all, I hope.
If i understand correctly, you want to take some commits from C into A.
If that´s the case, why don´t you "cherry-pick" them? It can lead to conflicts, but i think its your best chance :)
http://schacon.github.com/git/git-cherry-pick.html
http://schacon.github.com/git/user-manual.html#reordering-patch-series
You can try cherry-picking C's non-merge patches. Be prepared to handle merge conflicts. :)
精彩评论