xormapmap
xormapmap

Reputation: 49

Keep branch structure during git rebase

Let's say I have the following tree:

A -- B -- C -- D -- E       main
           \
            F -- G -- H     featureA
                  \
                   I        featureB

I'm working off featureA and want to update to latest main. If I git checkout featureA followed by git rebase main, it does not bring featureB branch along with it.

Here is what I want:

A -- B -- C -- D -- E                    main
                     \
                      F' -- G' -- H'     featureA
                             \
                              I'         featureB

Upvotes: -1

Views: 59

Answers (1)

eftshift0
eftshift0

Reputation: 30297

That has to be done by hand:

git rebase main featureA
git rebase G festureB --onto G'

You could use the old commit ID of featureA (that is, before it was rebased) instead of G in the second command or you could create a temporary branch where featureA is before the rebase so that you can use that branch after featureA is rebased.

Upvotes: 1

Related Questions