Merge / Redirect Branch Off in Git

Suppose Git has the following situation:

      X---Y feature
     /
A---B---C---D edge

Now I am reinstalling the branch edgeby changing bit B a bit (using edit), so now it looks like this:

      X---Y feature

A---E---C'---D' edge

C 'and D' coincide with C and D, but are applied on top of E (and notice that X in the branch featuredisconnected).

Now how can I:

  • Restore / merge a branch featureso that its fixations appear as if they were applied over D '?
  • Rebase / merge branch featureso that its commits appear as if they were applied on top of E, but without a separate โ€œmerging branch ...โ€ commit (both with C 'and D' are overwritten to become C '' and D ' ')?
+5
1

X -, B . feature edge, :

git checkout feature
git rebase edge

, , X E, :

git checkout feature
git rebase --onto <sha-of-E> <sha-of-B> feature
+5

All Articles