user3142695 user3142695 - 1 year ago 79
Git Question

Changing the starting commit of a new git branch

I forgot to do a

before creating a new branch. I did not recognize that, did the work and a finishing
. Now I see that the starting point of the new (and now merged) branch is wrong as it is too far in the past.

Is it possible to correct that?

Answer Source

Assume the history consists of two branches - master & topic. topic is the branch you created from master without doing a git pull.

git reset --merge ORIG_HEAD  // Undo git-merge
git checkout master
git pull
git rebase master topic  // Replay commits of topic on new master

After this you can proceed with merge (if required).

For more detail on undo git-merge, refer here

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