user3142695 user3142695 - 2 months ago 4x
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?


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