How to escape the git commit window from OS X terminal

gitterminal

I am just learning git and the terminal and I wanted to make a test commit but I cannot seem to be able to escape the text editor window to save the commitenter image description here

Best Answer

It looks like you're inside the vi editor. Typing :wq and pressing enter should do it, i.e. save the commit message and exit.

: enters the command mode, w is for "write" (save) and q is for "quit".

You may need to hit escape before :wq to exit the insert mode (vi is a mode based editor).

If you want to exit without saving hit escape, :q! and enter.

git opens your default editor so you can edit the commit message. You can change the default editor, even to graphical text editors (such as Sublime Text). See here for example.