Git 修改历史提交记录

git rebase -i 列出 commit 列表

#本地仓库没 push 到远程仓库的 commit 信息
$ git rebase -i
#最近5条
$ git rebase -i HEAD~5
#最近5条
$ git rebase -i HEAD~5
# 列出 rebase 的 commit 列表,不包含 <commit id>
$ git rebase -i <commit id>

找到需要修改的 commit 记录,把 pick 修改为 edit 或 e:wq 保存退出

修改 commit 的具体信息git commit --amend

$ git commit --amend --message="feat:修改的信息"  --author="XXX <XXX@163.com>"

git rebase --continue 继续(中间也可跳过或退出git rebase (--skip | --abort)

$ git rebase --continue

远程提交

$ git push

 

posted @ 2022-09-27 15:45  这个冬天有点冷  阅读(117)  评论(0编辑  收藏  举报