原因
有时候为了减少提交日志,并且添加的内容是与上次的内容属于同一个提交内容的,为了好维护,会将本次的提交追加到上次的提交中。
实现方式
git add .
git commit --amend --no-edit
可能遇到的问题
error: There was a problem with the editor 'vi'.
Please supply the message using either -m or -F option.
原因:之前没有配置 core.editor 选项。 配置core.editor 选项git config --global core.editor /usr/bin/vim 后再次运行git commit --amend 即可。
2、配置core.editor 后依然出现 1 的错误,那有可能是vim 有修改,或使用macvim 替换。 解决:使用如下命令git config --global core.editor $(which vim) 不指定vim 实际目录,使用变量引用。