Adding a git commit message using vi on OS X Adding a git commit message using vi on OS X git git

Adding a git commit message using vi on OS X


If you haven't change the default git's editor, that "new view" is the Vi program.

To save your commit message using Vi, follow the next steps:

  1. Type i
  2. Write your message
  3. Type the ESC key
  4. Type :wq
  5. DONE! :D

Typing :q, step 4, is not enough beacuse just means QUIT without saving. That's why you need :wq, which means WRITE and QUIT.

You can write your commit message using your favourite editor(vim, emacs, etc.). To achieve this, you can use configuration parameter or environment variables, listed in order:

  1. GIT_EDITOR environment variable
  2. core.editor configuration option
  3. VISUAL environment variable
  4. EDITOR environment variable

Using the configuration option type something like this:

$git config --global core.editor "nano"

Or if you want to use enviroment variables, add something like this to your .bash_profile

$export GIT_EDITOR="PATH/TO/YOUR/EDITOR"


By default Git will open Vim as editor.

You basically need to type 'I' to start editing. After that ESC and type :q to quit or :w to save the file. You can also combine them: :wq to save and exit Vim.

For more information about Vim check the official documentation

To change Vim for any other editor check the Git Environment Variables or older posts with a similar question:How do I make Git use the editor of my choice for commits?