2

I am going through a tutorial on git and my next task is to use a "git commit" command and use an editor to make my commit message. I can get the editor to come up but I always get the "Aborting commit due to empty message error." I looked at How do I make Git use the editor of my choice for commits? and Aborting commit due to empty commit message among other places and none of the options work. The --wait isn't legal and the -multiInst and -notabbar arguments didn't help. Also when I put the code in my C:\Users\Kendall.gitconfig git still uses the value I put in the core editor from the command line. I tried to use the -F flag in my .gitconfig file but it had no effect because it still used the value from the command line. Any help would be appreciated.

Community
  • 1
  • 1
ponder275
  • 813
  • 2
  • 8
  • 27
  • 3
    *Slow down.* I can infer that you're trying to use an editor you've got installed locally to create your commit messages. Let's start with the basics: what editor are you using? I presume you're on Windows, would you mind confirming that? – Makoto May 06 '15 at 19:37
  • 2
    have you saved the file before closing the editor? – Diego May 06 '15 at 19:44
  • I put all the info in because the instructions said to share my research. Sorry if it was too much. I tried notepad++ and wordpad on windows and I am using cygwin. I have saved the file with both of them, does it matter what name I use or where I save it? Both editors come up blank to start with. – ponder275 May 07 '15 at 01:43
  • Yes it matters, git needs to find it. It's somewhere under .git directory; but usually git creates it and then opens it, so you just have to use the save command which won't ask for a filename. Also the file comes with some comments initially. That's how it works in Linux, for instance. I'm not sure about Windows, though. – Diego May 10 '15 at 19:19
  • I just get a blank file with no comments so something isn't working right. – ponder275 May 13 '15 at 23:38
  • I found the answer to my problem. Notepad++ comes up with a blank new file but if I open ~/.git/COMMIT_EDITMSG and type in my message it works fine. I have to do the same thing if I do a revert. Thanks for the help! – ponder275 May 20 '15 at 18:25

4 Answers4

7

You are not saving the file in the editor therefore when git tries to read the temp file it sees no commit message.

The easiest thing for beginners is to use the -m flag and pass your message as a string in quotes.

git commit -m "commit message here"
Colin Schoen
  • 2,266
  • 1
  • 14
  • 24
2

I found the answer to my problem. Notepad++ comes up with a blank new file but if I open ~/.git/COMMIT_EDITMSG and type in my message it works fine. I have to do the same thing if I do a revert. Thanks for the help!

ponder275
  • 813
  • 2
  • 8
  • 27
0

Git commit ignores a line starting with #. If like the message generated by Git Bash , you need to change "#" to string "". Save message (and editor) , then commit will continue.

0

I just want to thank to Mr. John Zoetebier's answer above. (This answer can be just under his answer but I can't do that as I don't have enough credit? ... Anyway, if you do "git commit" to open Commit Editor, at the top of it, you should find:

# Please enter the commit message for your changes. Lines starting # with '' will be ignored, and an empty message aborts the commit.

So, if I want to use the comment automatically created based on the changes, I must remove all the # at the beginning of each line. But since I had many changes which made a very long comment displayed in the editor, I didn't notice such thing at the top and searching hours to figure out why it keeps me giving:

Aborting commit due to empty commit message.

even though I "Save"ed and checking it saved as COMMIT_EDITMSG. Hope anyone who got the same problem do not waste his/her time for such thing!