繁体   English   中英

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

[英]How to choose commit message in interactive git rebase

我对在交互式git中重新定位时如何选择提交消息感到困惑。 我看到此消息:

Please enter the commit message for your changes. Lines starting
with '#' will be ignored, and an empty message aborts the commit.

我只是想选择我的第一个提交的现有消息作为此基准的提交消息,但是我对如何完成此操作感到困惑。

如果要更改某个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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM