如果您已经将修订推送到某个地方:不要!
否则:使用git rebase -i <SOME_OLD_REVISION> 并使用r(eword) 选项标记要更改的提交。
关闭弹出的文件后,变基将开始,系统会提示您选择输入新提交消息的每个提交。
假设您有以下提交历史记录(最新的优先):
f6f6f6f last commit
d4d4d4d ...
c3c3c3c third commit
b2b2b2b second commit
a1a1a1a first commit
如果想更改b2b2b2b 和c3c3c3c 的消息,您可以这样做
git rebase -i a1a1a1a
接下来,您最喜欢的编辑器将弹出并显示此对话框:
pick f6f6f6f last commit
pick ...
pick c3c3c3c third commit
pick b2b2b2b second commit
# Rebase b2b2b2b..f6f6f6f onto a1a1a1a
#
# 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
对于提交b2b2b2b 和c3c3c3c,将pick 更改为r 或reword,保存文件并退出编辑器。
接下来,变基将开始。
对于您选择到reword 的提交,您可以输入新的提交消息。