当前位置: 代码迷 >> 综合 >> Git commit 设置提交日志编辑器
  详细解决方案

Git commit 设置提交日志编辑器

热度:48   发布时间:2024-01-16 04:33:44.0

git commit 提交变更时可使用命令行提供一条日志消息,如下所示:

         git commit -m "提交日志"

         git commit --message "提交日志"

更好的做法是在交互式编辑器会话期间创建消息,这样就可以在熟悉的编辑器里编辑一条详细的提交日志,想要在 Git commit 时打开你想使用的编辑器,需要设置 GIT_EDITOR 环境变量:

在 /etc/profile文件中加入下面其中一句:

         export GIT_EDITOR=vim

         export GIT_EDITOR=gedit

执行 source  /etc/profile,再次提交时就可以直接使用 git commit命令提交,然后会自动进入你设置的编辑器编辑提交日志。

另外一种方法是配置Git的core.editor配置选项:

         git  config  --global  core.editor   "vim"

         git  config  --global  core.editor   "gedit"

  相关解决方案