June 8, 2013

Error writing git commit messages with vi

I typically write my git commit messages in the terminal, but today I wanted to write a multi-line comment so I left out the -m argument to git commit so it would open up my default editor, which is vi:

git commit

I wrote my comment, saved and exit but got an error:

$ git commit
error: There was a problem with the editor 'vi'.
Please supply the message using either -m or -F option.

A quick google and I found the solution, I thought I’d repost it here for myself as well as others.

There are a couple of solutions offered in that article, for me I just set the full path to vi with a -f flag in my .gitconfig:

[core]
  editor = /usr/bin/vi -f

As an FYI…if you want to see the values in git config, you can run this command in your project and it will list your global and project configuration:

git config -l

© Michael Sharman 2017