# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
is precisely there for adding your commit message.
You press i
, and you enter insert
mode. You can navigate around the text and insert what ever you want.
When done, press Esc
. This makes you exit insert
mode.
Next you have to press :wq
, which means to write and quit.
This will save your commit message.
Git allows you to use an editor of your choice to enter a commit message. If you don't specify one, then the default editor is a system-specific default, usually vi
, which is a modal editor coming from Unix. As the Git FAQ says:
If you haven’t specified an editor specifically for Git, it will by default use the editor you’ve configured using the VISUAL
or EDITOR
environment variables, or if neither is specified, the system default (which is usually vi
). Since some people find vi difficult to use or prefer a different editor, it may be desirable to change the editor used.
(When I wrote this, it was rather tongue-in-cheek, since a great many people do find vi difficult to use because the editing paradigm differs from most other editors. “How to quit vim” is a common search topic.)
My recommendation here is to type Esc
and then :wq
(then Enter
) to quit vi and then configure the editor of your choice instead using the core.editor
option. The Git FAQ provides examples of how to do this properly. Once you've done that, you can attempt your commit or revert again.
If you don't have a preferred editor, nano is a relatively simple editor that I can recommend for this case. I don't believe it's shipped with Git for Windows, though, so you'll need to download it separately.
If you do want to learn to use vi, then I'd recommend the vimtutor program, which comes with Vim (which is the most common vi editor and the option shipped with Git for Windows) that will teach you how to use it properly.
Your git is configured to use vi
as a text editor (it is also the editor you will get if nothing else is defined).
You can change this editor to something else, for example :
you can use Notepad++ :
git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
or Visual Studio Code :
git config --global core.editor "code --wait"
or any text editor you like : just check the command line options you have to pass to your editor
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.