修改最近提交信息
git commit --amend --author “name <email>”
会弹出一个窗口,通过编辑器可以修改提交信息
注意会生成新的commit id
修改过去提交信息
先使用信息回滚,方法为rebase:
git rebase -i master~1 #最后一次
git rebase -i master~5 #最后五次
git rebase -i HEAD~3 #当前版本的倒数第三次状态
git rebase -i 32e0a87f #指定的SHA位置
然后再编辑命令:
pick:保留该commit(缩写:p)
reword:保留该commit,但我需要修改该commit的注释(缩写:r)
edit:保留该commit, 但我要停下来修改该提交(不仅仅修改注释)(缩写:e)
squash:将该commit和前一个commit合并(缩写:s)
fixup:将该commit和前一个commit合并,但我不要保留该提交的注释信息(缩写:f)
exec:执行shell命令(缩写:x)
drop:我要丢弃该commit(缩写:d)
这里使用的是上面的edit
接着就可以使用
git commit --amend --author “name <email>”
进行编辑了
编辑完成后,使用
git rebase --continue
继续下一条提交信息的编辑