git 更改远程commit信息

在将commit信息push到origin之后如果想更改commit信息可以使用git rebase -i 命令。具体方法如下

git commit --amend

例如,如果想要修改最近三次提交信息,或者那组提交中的任意一个提交信息,将想要修改的最近一次提交的父提交作为参数传递给 git rebase -i命令,即HEAD~2^ 或 HEAD~3。

git rebase -i HEAD~3


pick f7f3f6d changed my name a bit
pick 310154e updated README formatting and added blame
pick a5f4a0d added cat-file

# Rebase 710f0f8..a5f4a0d onto 710f0f8
# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit's log message
#  x, exec = run command (the rest of the line) using shell
# These lines can be re-ordered; they are executed from top to bottom.
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
# Note that empty commits are commented out

如果你想更改第一条commit 信息,把第一条commit信息对应的pick 更改为edit然后保存退出,运行

git rebase --amend


git rebase --continue


git push origin master --force

git commit 信息规范
关于git commit信息规范可以参照

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页