How to "abort" merge in IntelliJ Idea

39,591

Solution 1

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.

Solution 2

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

Share:
39,591

Related videos on Youtube

Jaroslav Záruba
Author by

Jaroslav Záruba

Updated on September 18, 2022

Comments

  • Jaroslav Záruba
    Jaroslav Záruba over 1 year

    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?

    • harrymc
      harrymc over 6 years
      Choose your case from here.
  • royalaid
    royalaid about 4 years
    This also works for most things with conflicts like reverts that result in needing a merge.
  • Philipp
    Philipp over 2 years
    This wasn't in the Git Branches for me, but in the Git menu.