While you are learning git commands, it’s easy to omit some essential part of a command. This will occasionally cause git to start a command line editor named Vim.
For example, the following command is missing a commit message:
$ git commit
Therefore, Git will start Vim, and prompt you to enter a commit message in the Vim editor window:
How to Exit Vim (:q)
If your screen looks similar to the above, you are in Vim. It’s not easy getting out. To exit the Vim editor and return to the shell, follow these steps:
- Hit the Esc key.
- Enter the following:
:q
(short for:quit
) - Hit the Enter key.
If you are still stuck, read more at Stack Overflow.
Switch Off Vim
To prevent git from sending you to vim in the future, use this config command:
git config --global core.editor="nano"