修改git commit消息
重写最近commit消息
commit还没有在线推送的情况
修改旧的或多个commit消息
修改最近推送的commit消息
git commit --amendgit push --force example-branch修改较老的或者多个commit消息
参考
Last updated
git commit --amendgit push --force example-branchLast updated
# 显示当前分支最近3个commit
git rebase -i HJEAD~3pick e499d89 Delete CNAME
pick 0c39034 Better README
pick f7fde4a Change the commit message but push the same commit.
# Rebase 9fdb3bd..f7fde4a onto 9fdb3bd
#
# 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 outpick e499d89 Delete CNAME
reword 0c39034 Better README
reword f7fde4a Change the commit message but push the same commit.git push --force example-branch