git修改历史commit信息

修改历史提交 commit 的信息
操作步骤:

  1. git rebase -i 列出 commit 列表
  2. 找到需要修改的 commit 记录,把 pick 修改为 edit 或 e,:wq 保存退出
  3. 修改 commit 的具体信息git commit --amend,保存并继续下一条git 4. 4. rebase --continue,直到全部完成
  4. 中间也可跳过或退出git rebase (–skip | --abort)
# 列出 rebase 的 commit 列表,不包含 <commit id>
$ git rebase -i <commit id>
# 最近 3 条
$ git rebase -i HEAD~3
# 本地仓库没 push 到远程仓库的 commit 信息
$ git rebase -i

# vi 下,找到需要修改的 commit 记录,```pick```修改为 ```edit```或 ```e```,```:wq```保存退出
# 重复执行如下命令直到完成
$ git commit --amend --only -m "modify message by daodaotest"
$ git rebase --continue

# 中间也可跳过或退出 rebase 模式
$ git rebase --skip
$ git rebase --abort

https://cloud.tencent.com/developer/article/1730774

猜你喜欢

转载自blog.csdn.net/frighting_ing/article/details/132294862