commit message窗口没有了,没法提交代码了,请问怎么处理,谢谢?
我的在侧边栏
全屏截图看看。或者点一下右侧时钟图标,选一个描述相近的先提交。
如果你发现在提交代码时缺少了commit message窗口,可能是因为你的git配置出了问题。解决方法如下:
git config --global core.editor
如果显示结果为空,说明没有设置默认编辑器,需要设置一个。比如:
git config --global core.editor "vim"
这里以vim为例,你也可以根据自己的使用习惯设置其他编辑器。
如果你已经设置了默认的编辑器,但是在提交代码时依然没有出现commit message窗口,那可能是因为默认使用的是一个空的编辑器。解决方法如下:
如果你使用的是git bash或者其他命令行工具,在提交代码时在当前命令行窗口中输入commit message即可(比如git commit -m "commit message"
)。
如果你使用的是图形界面的git工具,在提交代码时需要修改git配置文件。首先,你需要找到你本地仓库的.git目录,进入该目录的hooks子目录,找到prepare-commit-msg.sample文件。将该文件复制一份,并命名为prepare-commit-msg(不要包含任何后缀名)。修改该文件的内容,将以下代码:
``` #!/bin/sh # # An example hook script to prepare the commit message. # Called by "git commit" with one argument, the name of the file # that has the commit message. The hook should edit the file contents # in place, and not print anything to stdout. # # To enable this hook, rename this file to "prepare-commit-msg".
# This hook can be used to verify that the message contains a valid # git commit reference, and to update the message to include the content # of the commit(s) being referenced.
: ```
改为以下代码(注意添加你需要的commit message格式):
``` #!/bin/sh
if [ -z "$2" ] then echo "[type] commit messages" echo "[description] commit description" echo "[issues] fixed #issue_number" fi ```
保存文件并退出。然后在命令行中输入以下命令:
chmod +x prepare-commit-msg
这个命令会使prepare-commit-msg文件拥有可执行权限。之后你在提交代码时就会弹出含有你需要填写的commit message的窗口了。
如果以上方法都不能解决你的问题,建议你检查一下你的git版本是否过低或者重新安装git。如果问题仍然存在,可能需要进一步排查。