If you try to git commit
and don’t specify -m
for a message, or if you git pull
and there’s a non-fast-forward merge, or if you git merge
and there’s a non-fast-forward merge and you don’t specify -m
, or what I’m sure are a host of other reasons, you might get popped into an editor.
And you might not be familiar with that editor.
So here’s how to get out of it.
Nano: If the editor says “Nano” or “Pico” in the upper left, then edit the commit message (if you want), then then hit CTRL-X
, and then hit Y
to save, then ENTER
to accept the given filename.
Vim: If the screen has a bunch of ~
characters down the left and a crazy-looking file name at the bottom maybe with the word All
, you’re in Vim or some other vi (“vee eye”) variant. Press i
, then type a message (if you want), then hit the ESC
key in the upper left, then type two capital Z
s in a row. ZZ
. That should save and exit. Learning Vim57 is beyond the scope of this guide, but this author thinks it’s worth it for the editing speed you can achieve.