maolddv maolddv - 3 years ago 132
Git Question

Git and management rebase of branches

I create a new branch (pj2/new-register-feature) from [dev-project2] branch and I created a pull request to [dev-project2] branch. (pull request 1).

And then let's continue action rebase [dev-project2] to [dev-project1] and push force [dev-project2] branch after rebase.

But when I review [pull request 1] as above it was occur a lot of commit on [pull request 1] after rebased [dev-project2] to [dev-project1] branch.

So, Could you help me explain it and how to update [pull request 1] to only see commit of [pj2/new-registry-feature] which create pull request

Answer Source

Here is how I understood your question (please let me know if I missed something) :

You started from :

--A--B--C--D--E--F--G--H <- dev-project1
       \-c--d--e--f--g <- dev-project2
                 \-p--q--r <- pj2/new-register-feature

And created a pull request to merge pj2/new-register-feature into dev-project2.

Then you rebase dev-project2 onto dev-project1.

With the rebase completed, the graph now looks like :

--A--B--C--D--E--F--G--H <- dev-project1
      \                 \
       \-c--d--e-[f]-[g] \-c'--d'--e'--f'--g' <- dev-project2
                 \-p--q--r <- pj2/new-register-feature

What you observe in the merge request is :

  • instead of seeing : p--q--r as the history for your branch (wrt dev-project2),
  • you now see c--d--e--p--q--r

If you want to restore something closer to the initial graph, you would need to rebase pj2/new-register-feature on top of e' (that is : the rebased version of the original fork point between pj2/new-register-feature and dev-project2).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download