Skip to the content.

如何修改Git commit的信息

2017-11-21

原文地址: http://xiguada.org/change-git-commit-message

Git commit信息push后,如何修改,amend可以修改最后一次commit信息,但对于历史提交信息,需要使用rebase命令。

  1. 比如要修改的commit是倒数第三条,使用下述命令:
    git rebase -i HEAD~3
    

  1. pick改为edit

  1. 然后 :wq出现如下信息:

  1. 执行
    git commit --amend
    

    修改commit信息

  1. 退出保存 :wq
  2. 执行
    git rebase --continue
    
  3. 推送到服务端
    git push -f