Aborting commit due to empty commit message

后端 未结 20 2044
[愿得一人]
[愿得一人] 2020-12-04 09:45

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 g

20条回答
  •  猫巷女王i
    2020-12-04 09:55

    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. 
    

提交回复
热议问题