20

Started a merge between branches in source tree and changed my mind. Wanted to redo the merge but am getting the error when starting the merge again :

"fatal: You have not concluded your merge (MERGE_HEAD exists).Please, commit your changes before you merge."

Error

I cannot see any un-committed files but when clicking the "Commit", I get the previous merge changes.

How do I cancel this merge ?

Marco
  • 1,377
  • 15
  • 18
Yigal Omer
  • 301
  • 1
  • 2
  • 6

3 Answers3

48

You are in the merge process. If you need to abort the merge, You need to get out of the merge by using git merge --abort.

If not do a git status git status to figure out what the conflicts and changes are and then commit those changes to continue with the merge.

Yogesh_D
  • 17,656
  • 10
  • 41
  • 55
4

Since you have uncommitted code you can revert back to your HEAD

> git reset --hard HEAD

Muhammad Faizan
  • 1,709
  • 1
  • 15
  • 37
3

From this Atlassian doc resource:

Hit 'Revert' on the toolbar, but then click on the 'Reset All' tab and use that. This will reset the merge metadata too.

By the way, you might handle this from the Git command line using:

git reset --hard HEAD
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • Reset and revert are different things. Can you make sure that source tree’s revert is exactly that? – evolutionxbox Apr 10 '18 at 09:25
  • @evolutionxbox "Revert" in SourceTree is not a Git revert. It is more like an SVN revert, which is a reset in Git. Check the doc link in my answer. – Tim Biegeleisen Apr 10 '18 at 09:29
  • Of course you know the difference (I shouldn’t have said contrary). I’m not sure it’s a good thing that they mix up the terminology like that. – evolutionxbox Apr 10 '18 at 10:37
  • @evolutionxbox Yes, it's very irritating, especially when you're trying to help someone and they say "revert," but really what is happening is a reset. – Tim Biegeleisen Apr 10 '18 at 10:53