On Mac OS a and Unix systems Git defaults to using vim as the editor for commits.(I don’t know what the default is on Windows) You can change this, if you like, but for now I’ll just give a couple of tips for using vim — just enough to get by.
When Git needs a message for an action it will bring up vim in view mode. You can move around using the
k(line up) and
But for quick editing, the
i key will put you in editing mode where you can type and move around as you would for most editors. When you’ve finished press the
esc key to get you out of editing mode.
The normal command to save the message and quit is
:wq which is bit of a finger twister. An alternative is
ZZ which does the same thing, but it’s a much easier key combination to use.
A final thing. An empty commit message cancels the commit, (or rebase or tag, or whatever action the message is being added for). So if you change your mind just delete the message (the lines starting with the comment character
# don’t count). A useful way of doing this is to make sure you’re not in insert mode by pressing the
esc key and then using
dd which deletes the whole line.