Accidentally branched off of the wrong branch, and when I want to merge into the master I have to merge both branches

Spread the love

Question Description

So I created a branch off of another branch I was already creating, and now when I try to merge the branches into master, I have run into the situation where I have to merge both branches.

Here is a diagram

Master->

 ->Branch 1  -> Branch 2

I want to be able to merge just the changes on branch 2 onto master without having to merge the changes on Branch 1 if that makes sense. I looked into reset and revert, but it seems like these things will delete all the changes I made with branch 2. Any ideas?

Thanks

Practice As Follows

Try git rebase –onto with the following syntax:

To put branch2’s changes on to the master without including branch1’s

git rebase --onto master branch1 branch2

http://git-scm.com/book/en/Git-Branching-Rebasing

Leave a Comment