比如要修改的 commit 是倒數第三條,使用下述命令:
git rebase -i HEAD~3
其輸出類似:
pick commit_id_1
pick commit_id_2
pick commit_id_3
假如修改 commit_id_1 的提交信息,將其前面的 pick 改為 edit,之后 wq 保存。然后執行:
git commit --amend
修改提交的信息,並 wq 保存。
執行:
git rebase --continue
推送:
git push -f
