I have two branches: master and bonbon
Currently they are at the same point. The bonbon was a side project that was going to be released but has now been put on hold. I would like to revert the master branch to a point before the bonbon branch was created. However I would also like to keep some of the changes I made in the bonbon branch and in the future it might be required to merge back in the bonbon branch so I don’t want to lose those changes. What is the best way to revert the master branch and pick out the required changes.
I tried to reset the branch but when I commited and push the changes it failed and I’ve ended up merging the two branches together again! Should I have done a hard push (edit: i meant force push)?
My guess is that by resetting the branch you meant something like this, while on the
masterbranch:In this case, a push will fail, because a push on a particular branch, by default, requires that the merge (of the remote branch with your local branch) is a fast forward, that is, that the remote’s ref is an immediate parent to your local ref.
So, you have no other choice than to force the push — either with
git push --force, or withgit push +localref:remoteref(the local ref spec can be omitted if the remote ref has the same name).For instance: