3

I am a bit confused about what branch to select in the ' Revert in branch ' dropdown while reverting a merge. I accidentally merged the 'test-1' branch into the Master branch. Now I want to revert it, but so I would click the revert button as shown below:

enter image description here

Clicking the button shows the following popup:

enter image description here

I am really confused about which branch should I pick in the dropdown. I want to revert the merge of test-1 and master.?

lynxx
  • 544
  • 3
  • 18
  • Better to revert the commit from test-1 branch and then again merge that branch to master. Avoid reverting it directly on master branch as it will change master branch history. – Dev-vruper Dec 19 '20 at 13:39
  • @Dev This is a revert, not a reset. No history is changing. – grg Dec 20 '20 at 13:19
  • @grg That doesn't appear to be the case. From the GitLab modal pictured above: "This will create a new commit in order to revert the existing changes." I'm not sure what your definition of reset and revert are, but it's apparent that your assertion that "No history is changing." is incorrect. – Joel Mellon Sep 29 '21 at 18:13
  • Anyway, this is a great question. As obvious as it seems on first glance, doubt is cast by being prompted with the question at all. Why would this be an option on an MR that inherently had a target branch? At the very least, the dropdown should default to the target branch that was merged into, not the repo's default branch (in most cases: master). GitLab UI design completely baffles sometimes. – Joel Mellon Sep 29 '21 at 18:16
  • @Joel Please see the difference between `git reset` and `git revert`, e.g. https://stackoverflow.com/a/45120157/1549818. The popup says "create a new commit", therefore history is not changing, as one is only appending a new commit to the existing history. This is reverting a previous change by making a new change that is the inverse. A reset would move the branch ref earlier in history, as if the original change never happened, a completely different operation. GitLab's UI design is perfectly reasonable: the correct option to pick here *is* master (see answer). – grg Sep 29 '21 at 18:20
  • @grg Ahh, the wording we're both using isn't aligned. The "history" in the context of the commit log doesn't change. You're saying that history isn't rewritten. I see. – Joel Mellon Sep 30 '21 at 18:26

1 Answers1

6

You merged test-1 into master, so master contains changes from test-1.

You no longer want master to have these changes, so you Revert in branch: master.

grg
  • 5,023
  • 3
  • 34
  • 50