使用 git rebase 修改commit message
2016-09-04 本文已影响294人
HeminWon
适用场景:在实际开发项目中,在commit的时候需要按照团队约定的规范编写commit message的内容。个人偶尔会有需要修改commit meaage的需求,下面是更改的方法以及可能会遇到的问题。
- 在此过程中遇到'vi'的error导致最后无法成功:
error: There was a problem with the editor 'vi'.
Please supply the message using either -m or -F option.
GitHub的Issues中的解决方法:
git config --global core.editor /usr/bin/vim
commit 没有 git push 前的解决方法
如Image001
假设在本地进行四次commit,第三次提交信息003 test
希望更改为003
![](https://img.haomeiwen.com/i325211/d4ae0956c541070d.png)
- Terminal中进入对应的commit
git rebase -i HEAD~2
![](https://img.haomeiwen.com/i325211/de4c0726942f2c75.png)
- 按照vi提示修改提交内容
Image003.png
进入Image004界面输入E
重新编辑commit内容
Image004.png
![](https://img.haomeiwen.com/i325211/c6126d76a50851c1.png)
![](https://img.haomeiwen.com/i325211/9c2d85f33efd7aaf.png)