【发布时间】:2018-11-10 23:08:10
【问题描述】:
您可以通过编程方式仅编辑最后一条提交消息:
git commit --amend -m 'xxxxxxx'
或者以交互方式随机提交:
git rebase -i HEAD~n
# Vim opens up, select the commit you want to modify, and change the word "pick" for "edit"
git commit --amend -m "Changing an old commit message!"
git rebase --continue
如何将两者结合起来?我想以编程方式更改消息,但要更改为先前的提交,而不仅仅是最后一个。
我要修改的提交已经被推送到 git 服务器,但让其他人重新同步 git 项目不是问题。
【问题讨论】:
-
为什么
rebase -i不适合你? -
到底是什么问题?无法编辑消息或推送到服务器?
-
@destoryer。我认为这个问题在这两个方面都很清楚......
-
git rebase -i有一个“改写”选项。如果您只更改一个提交的提交消息,则应该这样做。
标签: git git-rebase git-commit git-amend