I accidentally merged my branch, that has multiple commit's itself, to a release branch. Within seconds of me merging, several other branches were merged in afterwards. The git log for the release branch looks like:
commit d942b01c89369e6be474f054a66d8cc1a0d7d59f
Merge: cd1db2c632a f2096c4685e
Author: someone else
commit 285d8d69a0abe17c2d6875aaee97003e206618f4
Merge: 4e5fae9a588 1665c1da9fd
Author: me
updates
commit 1665c1da9fdec15a9325fa58dad25064a189f366
Author: me
updates
commit 661aa3620ec444eabe7a251c6e9662185337fb4c
Merge: 66b06e87d85 2d58cc43674
Author: me
updates
commit 66b06e87d85ec0c6702ad7fdee555f52bc47ca89
Author: me
updates
commit f3162b881507609a2b7ded077f02c272e6ca7bb7
Author: me
updates
commit 4e5fae9a58893e05f9853d24dd71f4e140f49165
Merge: 53f93040834 2d58cc43674
Author: someone else
So I can't just reset the head to 4e5fae9a58893e05f9853d24dd71f4e140f49165 (I think I'm understanding that correctly) because of the merges that came afterwards. I just need to "undo" the merge that brought in the commits by me
CodePudding user response:
You can git revert -m 1 285d8d69
.
Note that you will then be unable to merge any of the commits in that branch later, because although the effect of the merge will be undone, the topology of the merge will remain (and there's nothing you can do about that at this point). This is the situation discussed at length in the famous explanation at https://github.com/git/git/blob/master/Documentation/howto/revert-a-faulty-merge.txt, which provides solutions to the difficulty in case you want to perform the merge later.