vim - How do I exit from the text window in Git?

ID : 10237

viewed : 27

Tags : gitvimgit

Top 5 Answer for vim - How do I exit from the text window in Git?

vote vote

100

Since you are learning Git, know that this has little to do with git but with the text editor configured for use. In vim, you can press i to start entering text and save by pressing esc and :wq and enter, this will commit with the message you typed. In your current state, to just come out without committing, you can do :q instead of the :wq as mentioned above.

Alternatively, you can just do git commit -m '<message>' instead of having git open the editor to type the message.

Note that you can also change the editor and use something you are comfortable with ( like notepad) - How can I set up an editor to work with Git on Windows?

vote vote

86

There is a default text editor that will be used when Git needs you to type in a message. By default, Git uses your system’s default editor, which is generally Vi or Vim. In your case, it is Vim that Git has chosen. See How do I make Git use the editor of my choice for commits? for details of how to choose another editor. Meanwhile...

You'll want to enter a message before you leave Vim:

O

...will start a new line for you to type in.

To exit (g)Vim type:

EscZZ or Esc:wqReturn.

It's worth getting to know Vim, as you can use it for editing text on almost any platform. I recommend the Vim Tutor, I used it many years ago and have never looked back (barely a day goes by when I don't use Vim).

vote vote

71

That's the vi editor. Try ESC :q!.

vote vote

69

On Windows 10 this worked for me for VIM and VI using git bash

"Esc" + ":wq!" 

or

"Esc" + ":q!" 
vote vote

55

On windows I used the following command

:wq 

and it aborts the previous commit because of the empty commit message

Top 3 video Explaining vim - How do I exit from the text window in Git?

Related QUESTION?