Aborting commit due to empty commit message

As a newbie git user, when I try to commit my work with

git commit -a -v

and I enter a commit message in my editor, I close the file, and get this error:

Aborting commit due to empty commit message.

I have read nearly all the topics addressing to this issue, changed editors, basically tried everything but nothing helps. What should I do?

One thing I noticed, while trying the whole process with notepad++, the file couldn't be saved.

A possible workaround is this:

git commit -am "SomeComment"

But by doing so I feel I am kind of nullifying the purpose of using git. I want to properly document my changes.


When you set an editor in the configuration of Git, make sure to pass the parameter "-w" to force Git to wait your commit message that you would type on your custom editor.

git config --global core.editor "[your editor] -w"

This error can happen if your commit comment is a single line starting with a # character. For example, I got this error when I ended up with the following in my commit message text editor window:

#122143980 - My commit message was here. The number to the left is a Pivotal Tracker story/ticket number that I was attempting to reference in the commit message.
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch [MYBRANCH]
# Your branch is up-to-date with 'origin/[MYBRANCH]'.
#
# Changes to be committed:
#   modified:   [MYFILE1]
#   modified:   [MYFILE2]
#

The problem, of course, is that my commit message started with a # character, so git saw that line as a comment, and consequently saw the commit message as being empty, as it had nothing but comments!

The fix was to start my commit message with a character other than #.

In my specific case, enclosing the Pivotal ID in square brackets made both git and Pivotal happy:

[#122143980] My commit message here. 

For Visual studio Code

git config --global core.editor "code -w"

For atom

git config --global core.editor "atom -w"

For sublime

git config --global core.editor "subl -w"

If you want to commit with a proper (long, multi-line comment) documentation, but don't want the -m option, what you can do (and that I do when preparing my commits) is to:

  • write your documentation (while you are making the changes) in a separate file 'doc-commit' (or whatever name you want to call it)
  • commit with a 'git commit -a -F /path/to/doc-commit')

In short, use a separate file (which can be at any path you want) as your commit message.


I'm also a newbie in Git. I encountered basically the same problem as yours. I solved this by typing:

git commit -a -m 'some message'

The reason is that git doesn't allow commit without messages. You have to associate some messages with your commit command.