gpt4 book ai didi

git - 如何编辑/修改 Git 中最后一次提交的提交消息?

转载 作者:太空狗 更新时间:2023-10-29 14:32:50 25 4
gpt4 key购买 nike

this popular answer in SO 所示,当我需要编辑/更正上次提交的消息时,我会:

git commit --amend -m "New commit message"

但是,当我想修改最后一次提交之前的提交消息时,我应该怎么办?例如,最后的第 14 次提交 - 还考虑到提交尚未推送到远程?

有没有一种方法可以在不重置以前的提交的情况下执行此操作?在这种情况下,rebase 是正确的做法吗?

最佳答案

您需要此处提到的交互式 rebase :How to modify a specified commit in git?

不同之处在于,您不需要edit,而是只想reword有问题的提交,因为您只想编辑提交消息。

这是另一个有用的资源:https://help.github.com/articles/interactive-rebase

edit: reword 仅适用于 OP 指出的 1.6.6 或更新版本。

关于git - 如何编辑/修改 Git 中最后一次提交的提交消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22487473/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com