Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在交互式git rebase中选择提交消息_Git - Fatal编程技术网

如何在交互式git rebase中选择提交消息

如何在交互式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

我不知道在交互式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并选择
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

执行强制推送可能会给使用分支的其他人带来一些问题,因此在执行此操作之前请仔细考虑。

请查看下面给出的答案。