8

I am new to this, so apologies about the basic question.

I am using an Ubuntu environment. I have git installed. I setup vimdiff as the merge tool.

I am testing the environment, but I am having a problem.

I created a conflict in a readme.txt file. The conflict obviously happens when I try to merge from the branch develop to master. As expected, some "markup characters" are added to readme.txt to indicate where the conflicts happen. So, the next step is to call git mergetool which launches vimdiff.

So far, everything is working as expected, and vimdiff is now launched. But then, I decided to exit vimdiff without making any changes. I wanted to "postpone" my changes till another time. So, I press <ESC> followed by :qa!, thinking this will stop the merge process. Unfortunately, this is not what happened. It looks like that the merge is now considered resolved and successful, and the readme.txt file, although did not change, and although contains the conflicts markup, is now ready to be committed.

Now to my question. How can I terminate the git mergetool call, exit vimdiff, and start over, as if I did not make the call?

Thanks.

Greeso
  • 7,544
  • 9
  • 51
  • 77
  • 1
    Try to [exit `vim` with error code](https://stackoverflow.com/a/29419286/7976758). – phd Feb 01 '20 at 07:50

2 Answers2

14

Use :cquit, or git merge --abort and do the merge again.

D. Ben Knoble
  • 4,273
  • 1
  • 20
  • 38
-2

For Windows solution is:

  1. type :qa

  2. press <Enter>

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
  • This is wrong. `:qa` quits all open windows and exits Vim with no error code (docs: https://vimdoc.sourceforge.net/htmldoc/editing.html#write-quit), which git considers to be a successful merge of the file. On top of that the OP specifically states that `:qa` does not give the desired result. The accepted answer is correct. – Jordan Jun 15 '23 at 17:04