Change the departure point of a branch in Egit

72 views Asked by At

I have the following situation :

branch A|   branch master
        |   |
        |   |
        |   |   branch B
        |   |   |<------B2
        |   |___|<------B1
        |   |<--------some commits (*) in B and in master, but not in A
        \___|
            |

I created a branch B from master but that was a mistake, I should have created B from A, and not from master.

So my initial thought was to Rebase B onto A. The problem with this approach is that the commits (*) are also rebased in B, which I don't want. So I wanted to use "cherry-picking" to duplicate the commits from B (after the divergent point with master) into A. But since Egit uses Interactive Rebase to do that, the problem is the same. The commits (*) are present in A.

Basically, I want to apply the functional changes introduced by B1 and B2 in the branch A, without the changes introduced by (*). The only solution that I found is to manually 'create Patch' for B1 and apply it in A, and then 'create Patch' for B2, and apply it in A.

Is there another way to easily do what I want to achieve using Egit ?

1

There are 1 answers

3
Joseph K. Strauss On

In the command line:

git rebase --onto a last-ignored-commit b

or

git rebase --onto a first-wanted-commit~ b

If you are already on branch-b you do not need to specify that as the last argument. Both commands evaluate to the same thing. The tilde (~) means find the first parent. Therefore last-ignored-commit and first-wanted-commit~ both refer to the same commit.