我在承诺信中写错了。

我怎么能改變訊息呢?承諾尚未推動。


当前回答

修正

这里有几种选择,你可以

git commit --amend

只要是你最后的承诺。

互动降落

否则,如果不是你的最后承诺,你可以做一个互动的折扣,

git rebase -i [branched_from] [hash before commit]

接下来,在互动的复制中,你只会添加编辑到这个承诺。当它出现时,做一个 git commit - 更改并修改承诺消息. 如果你想在这个承诺点之前旋转,你也可以使用 git reflog 并只会删除这个承诺。

其他回答

如果您正在使用 Git GUI 工具,则有一个按钮称为 修改最后的承诺. 点击该按钮,然后它将显示您的最后的承诺文件和消息. 只需编辑该消息,您可以承诺它一个新的承诺消息。

或使用此命令从控制台/终端:

git commit -a --amend -m "My new commit message"

我更喜欢这样:

git commit --amend -c <commit ID>

否则,将有一个新的承诺与一个新的承诺ID。

您可以使用 git-rebase-reword

它旨在以同样的方式编辑任何承诺(不只是最后) - 修改

$ git rebase-reword <commit-or-refname>

它被命名为反对互动的行动,以改变一个承诺:“反对”。 查看此帖子和人 - 部分互动模式-

例子:

$ git rebase-reword b68f560
$ git rebase-reword HEAD^

如果你只是想编辑最新的承诺,使用:

git commit --amend

git commit --amend -m 'one line message'

但是,如果你想连续编辑多个命令,你应该使用重定向,而不是:

git rebase -i <hash of one commit before the wrong commit>

此分類上一篇

在文件中,如上面的文件中,输入编辑或其他选项之一,然后点击保存和输出。

现在你将处于第一个错误的承诺,在文件中进行更改,它们将自动为你排列。

git commit --amend

保存和输出这个和类型

git rebase --continue

移动到下一个选择,直到完成所有的选择。

请注意,这些事情在这个特殊的承诺之后改变了您的所有SHA<unk>。

我喜欢使用以下内容:

git status git add --all git commit -am “消息走到这里关于变化” git pull <origin master> git push <origin master>