How to "abort" merge in IntelliJ Idea

9

1

Let's say I am merging and just before the push I decide that I do not want to merge. Is it possible to get rid of the commits I have merged (and not pushed yet) without deleting my local branch or going into command line?

Jaroslav Záruba

Posted 2018-01-18T08:10:08.050

Reputation: 718

1

Choose your case from here.

– harrymc – 2018-01-18T08:58:34.657

Answers

11

Happened to me while getting both push and pull failures:

  • "Push to origin/master was rejected"
  • "You have not concluded your merge (MERGE_HEAD exists). Please, commit your changes before you can merge"

To resolve:

  1. Go to "Version Control" window --> "Log" tab.
  2. Right click the previous commit --> "Reset Current Branch to Here..."
  3. In Git reset select "Mixed" (it keeps local changes).
  4. If there are later commits that were already pushed --> Pull from remote and merge as required.
  5. Commit the new changes, and Push to remote.

Noam Manos

Posted 2018-01-18T08:10:08.050

Reputation: 771

7

In the latest versions of IntelliJ (and I suppose other JetBrains products) there is a new option in the "Git branches" menu (bottom right of the screen) conveniently named "Abort Merge"...

Git branches menu

Olivier Gérardin

Posted 2018-01-18T08:10:08.050

Reputation: 171

This also works for most things with conflicts like reverts that result in needing a merge. – royalaid – 2020-02-25T05:43:16.743