git 由于空消息而中止提交
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30085970/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Aborting commit due to empty message
提问by ponder275
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 messageamong 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.
我正在学习关于 git 的教程,我的下一个任务是使用“git commit”命令并使用编辑器来制作我的提交消息。我可以让编辑器出现,但我总是收到“由于空消息错误而中止提交”。我查看了如何让 Git 使用我选择的编辑器进行提交?并且由于其他地方的空提交消息而中止提交并且没有任何选项起作用。--wait 不合法,-multiInst 和 -notabbar 参数没有帮助。此外,当我将代码放入 C:\Users\Kendall.gitconfig 时,git 仍然使用我从命令行放入核心编辑器的值。我尝试在我的 .gitconfig 文件中使用 -F 标志,但它没有效果,因为它仍然使用命令行中的值。任何帮助,将不胜感激。
回答by Colin Schoen
You are not saving the file in the editor therefore when git tries to read the temp file it sees no commit message.
您没有在编辑器中保存文件,因此当 git 尝试读取临时文件时,它看不到提交消息。
The easiest thing for beginners is to use the -m flag and pass your message as a string in quotes.
对于初学者来说,最简单的事情是使用 -m 标志并将您的消息作为引号中的字符串传递。
git commit -m "commit message here"
回答by ponder275
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!
我找到了我的问题的答案。Notepad++ 出现了一个空白的新文件,但如果我打开 ~/.git/COMMIT_EDITMSG 并输入我的消息,它就可以正常工作。如果我进行还原,我必须做同样的事情。谢谢您的帮助!
回答by John Zoetebier
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.
Git commit 忽略以 # 开头的行。如果像 Git Bash 生成的消息,则需要将“#”更改为字符串“”。保存消息(和编辑器),然后提交将继续。
回答by Kazuo Nakamura
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:
我只想感谢上面 John Zoetebier 先生的回答。(这个答案可以在他的答案之下,但我不能这样做,因为我没有足够的信用?......无论如何,如果你执行“git commit”以打开提交编辑器,在它的顶部,你应该找:
#
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!
即使我“保存”并检查它保存为 COMMIT_EDITMSG。希望遇到同样问题的人不要浪费时间在这种事情上!