git commit 新修改的内容 添加到上次提交中 减少提交的日志

有时候提交过一次记录只有,又修改了一次,仅仅是改动一些较少的内容,可以使用git commit --amend. 添加到上次提交过程中;

    --amend               amend previous commit
git commit --amend  # 会通过 core.editor 指定的编辑器进行编辑
git commit --amend --no-edit   # 不会进入编辑器,直接进行提交

如果你之前没有配置 core.editor 选项的时候,会出现:

error: There was a problem with the editor 'vi'. 
Please supply the message using either -m or -F option.

这个时候,你通过 git config 命令,配置全局变量,指定特定的编辑器就解决报错了;之后再进行git config --amend 命令来进行编辑;

git config --global core.editor /usr/bin/vim

保持更新,转载请注明出处。更多关于linux和分布式系统相关的知识,请关注 cnblogs.com/xuyaowen 

猜你喜欢

转载自www.cnblogs.com/xuyaowen/p/git-commit-amend.html