Return to merged branch

I have my main branch, then I worked on another function, combined it with my local master, and then transferred it to Github.

Now I need to delete all the changes that have occurred as a result of this merger, before further notice, but be able to merge them back at a later point in time.

How can i achieve this?

+4
source share
1 answer

You have to figure out which of the commits before the merge is the β€œmain line”, i.e. the part you want to keep. You can do this using git log :

 commit b556759a560650506da58e59f6a7c6a2c4bcb8f4 Merge: e3dac0d 090ad85 

... and a visual inspection of the two parent commits. (It seems that git merge foo will always put HEAD in the first position of the parent list and foo head in the second, but I'm not sure if this is guaranteed.)

Suppose e3dac0d is the main line, so we want to return the merge 090ad85 , then this

 git revert -m e3dac0d b556759 

For more information, see return erroneous merge with Torvalds and Hamano.

+4
source

All Articles