作为一个新手git用户,当我尝试提交我的工作时
git commit -a -v
Run Code Online (Sandbox Code Playgroud)
我在编辑器中输入提交消息,我关闭文件,并收到此错误:
Aborting commit due to empty commit message.
Run Code Online (Sandbox Code Playgroud)
我已经阅读了几乎所有涉及这个问题的主题,改变了编辑,基本上尝试了一切,但没有任何帮助.我该怎么办?
有一点我注意到,在使用notepad ++尝试整个过程时,无法保存文件.
一个可能的解决方法是:
git commit -am "SomeComment"
Run Code Online (Sandbox Code Playgroud)
但通过这样做,我觉得我有点无效使用git的目的.我想正确记录我的更改.
小智 115
在Git配置中设置编辑器时,请确保传递参数"-w"以强制Git等待您在自定义编辑器上键入的提交消息.
git config --global core.editor "[your editor] -w"
Run Code Online (Sandbox Code Playgroud)
Jon*_*der 32
如果您的提交注释是以#字符开头的单行,则会发生此错误.例如,当我在提交消息文本编辑器窗口中结束以下内容时,我收到此错误:
#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]
#
Run Code Online (Sandbox Code Playgroud)
当然,问题是我的提交消息以#字符开头,因此git将该行视为注释,因此将提交消息视为空,因为它只有注释!
修复是用除了以外的字符开始我的提交消息#.
在我的特定情况下,将Pivotal ID括在方括号中使得git和Pivotal都很高兴:
[#122143980] My commit message here.
Run Code Online (Sandbox Code Playgroud)
Arm*_*min 12
对于Visual Studio Code
git config --global core.editor "code -w"
Run Code Online (Sandbox Code Playgroud)
对于原子
git config --global core.editor "atom -w"
Run Code Online (Sandbox Code Playgroud)
对于崇高
git config --global core.editor "subl -w"
Run Code Online (Sandbox Code Playgroud)
我也是Git的新手.我遇到了和你一样的问题.我输入以下内容解决了这个
git commit -a -m 'some message'
Run Code Online (Sandbox Code Playgroud)
原因是git不允许在没有消息的情况下进行提交.您必须将某些消息与commit命令相关联.
首先删除编辑器的旧条目:
git config --global --unset-all core.editor
git config --unset-all core.editor
Run Code Online (Sandbox Code Playgroud)
设置你的编辑器:
对于记事本++
git config --global core.editor "Notepad++ -w"
git config core.editor "Notepad++ -w"
Run Code Online (Sandbox Code Playgroud)为了崇高
git config --global core.editor "Notepad++ -w"
git config core.editor "subl -w"
Run Code Online (Sandbox Code Playgroud)小智 5
我遇到了这个问题.我刚刚安装了1.8.0,我发现我不得不稍微修改上面的内容.我对这一切都非常新,但基本上看来,在提交时,它将使用content.editor,而不是core.editor,至少如果你为content.editor设置了一些东西.
所以,它是
git config --global content.editor "pico -w"
Run Code Online (Sandbox Code Playgroud)
最后让我承诺!显然,当然,使用你使用的任何编辑器.
希望有一天这会帮助某人!
| 归档时间: |
|
| 查看次数: |
61223 次 |
| 最近记录: |