如何在交互式git rebase中选择提交消息
我不知道在交互式git中重定基址时如何选择提交消息。我看到这个信息:如何在交互式git rebase中选择提交消息,git,Git,我不知道在交互式git中重定基址时如何选择提交消息。我看到这个信息: Please enter the commit message for your changes. Lines starting with '#' will be ignored, and an empty message aborts the commit. 我只是想选择我的第一次提交的现有消息作为此rebase的提交消息,但我对如何完成此操作感到困惑。如果您想更改某个Git提交的消息,可以使用交互式rebase并选择re
Please enter the commit message for your changes. Lines starting
with '#' will be ignored, and an empty message aborts the commit.
我只是想选择我的第一次提交的现有消息作为此rebase的提交消息,但我对如何完成此操作感到困惑。如果您想更改某个Git提交的消息,可以使用交互式rebase并选择
reword
作为该提交旁边的选项。例如,如果要更改4次提交之前的消息,可以执行以下操作:
git rebase -i HEAD~4
pick n3j9sj2 Comment for your most recent commit
pick b9de4la Comment for next most recent commit
pick 78er2nm Comment for an older commit
reword k2nbet3 Here is the commit you want to change
现在,当编辑器屏幕出现时(您在问题中引用了该屏幕),您可以输入您想要的任何提交消息。保存并退出时,应更改SHA-1为k2nbet3
的提交消息
请注意,您必须通过以下方式强制将分支推出到远程:
git push --force origin branch_name
执行强制推送可能会给使用分支的其他人带来一些问题,因此在执行此操作之前请仔细考虑。请查看下面给出的答案。