How do I exit from the text window in Git?

GitVim

Git Problem Overview


I am using Windows and before committing, Git wants me to enter a text message and a new text window appears.

screenshot

How can I exit from this?

I am trying to learn Git. So, a little help will be highly appreciated.

Git Solutions


Solution 1 - Git

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) - https://stackoverflow.com/questions/10564/how-can-i-set-up-an-editor-to-work-with-git-on-windows

Solution 2 - Git

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 https://stackoverflow.com/q/2596805/78845 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).

Solution 3 - Git

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

Solution 4 - Git

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

"Esc" + ":wq!"

or

"Esc" + ":q!"

Solution 5 - Git

On windows I used the following command

:wq

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

Solution 6 - Git

First type

 i

to enter the commit message then press ESC then type

 :wq

to save the commit message and to quit. Or type

 :q!

to quit without saving the message.

Solution 7 - Git

On windows, simply pressing 'q' on the keyboard quits this screen. I got it when I was reading help using '!help' or simply 'help' and 'enter', from the DOS prompt.

Happy Coding :-)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionnewbieView Question on Stackoverflow
Solution 1 - GitmanojldsView Answer on Stackoverflow
Solution 2 - GitJohnsywebView Answer on Stackoverflow
Solution 3 - GitJ-16 SDiZView Answer on Stackoverflow
Solution 4 - GitatazminView Answer on Stackoverflow
Solution 5 - GitRiya AbrahamView Answer on Stackoverflow
Solution 6 - GitPrashant Kumar GuptaView Answer on Stackoverflow
Solution 7 - GitAbhinav SaxenaView Answer on Stackoverflow