Find previous fork point after branch rebase

Viewed 61

I had a respository as

  A -- B -- C -- D    (master)
       \
         E -- F -- G  (feature)
              \
                ---H  (subfeature)

And ran git rebase master feature resulting in

                    --E'--F'--G'  (feature)
                  /
  A -- B -- C -- D                (master)
              \
                ---E--F--H        (subfeature)

After I made this mess I would like to now rebase subfeature to something like

  A -- B -- C -- D                  (master)
                  \
                   E' -- F' -- G'   (feature)
                        \
                          ---H"     (subfeature)

I suppose if I could find out the new commit for F' I could try to rebase onto that right?

1 Answers

I think that your branch diagram for the state of things after the rebase is incorrect, and it should look like this instead:

feature:                 E' -- F' -- G'
                        /
master: A -- B -- C -- D
              \
subfeature:    E -- F -- H

Note that rebasing the feature branch should not affect the subfeature branch, which should still have the same chain of commits going back to the B commit in master.

If you want the sub feature's HEAD H commit to sit on top of the F' commit in the rebased feature branch, you may use git rebase --onto:

git checkout subfeature
git rebase --onto F' F

The second command says to rebase the subfeature branch such that the commit whose parent is now F sits on top of a new base F' commit.

Related