Pergunta

Suppose we have the following situation in Git:

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

Now I rebase the edge branch changing the B commit a little bit (using edit) so it now looks like this:

      X---Y feature

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

C' and D' are the same commits as C and D, but applied on top of E (and notice that X within the feature branch became disconnected).

Now how can I:

  1. Rebase/merge the feature branch so that its commits appear as if they were applied on top of D'?
  2. Rebase/merge the feature branch so that its commits appear as if they were applied on top of E, but without a separate 'merging branch ...' commit (and with C' and D' being rewritten to become C'' and D'')?
Foi útil?

Solução

X doesn't become disconnected per-se, it still has the original B as its parent. If you want to subsequently rebase feature on top of edge, then:

git checkout feature
git rebase edge

If you wish to change the tree so that it has a similar structure to the original version, but with X as a child of E, that's:

git checkout feature
git rebase --onto <sha-of-E> <sha-of-B> feature
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top