我在承诺信中写错了。

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


当前回答

修正

这里有几种选择,你可以

git commit --amend

只要是你最后的承诺。

互动降落

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

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

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

其他回答

我添加了 Aliases reci 和 recm for recommit (amend) 它. 现在我可以用 git recm 或 git recm -m:

$ vim ~/.gitconfig

[alias]

    ......
    cm = commit
    reci = commit --amend
    recm = commit --amend
    ......

正如前面提到的那样, git commit --amend 是重写最后一份重写的方式。

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

我使用Git GUI尽我所能,这给了你更改最后的承诺的选项:

此分類上一篇

此外, git rebase -i 起源/masteris 一个可爱的 mantra 将始终向您介绍您在主人的顶部所做的承诺,并为您提供更改、删除、重新订单或破坏的选项。

您可以使用 Git 重定向. 例如,如果您想要修改回来承诺 bbc643cd,运行

$ git rebase bbc643cd^ --interactive

在默认编辑器中,修改“选择”到“编辑”的行,您想要修改的承诺。

$ git add <filepattern>

现在你可以使用

$ git commit --amend

要改變承諾,然後

$ git rebase --continue

要回到前任首席执行官。

更改最新承诺消息

git commit --amend

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

...任何人,这可能会使多线承诺消息或小纠正更有吸引力进入。

确保您在做此之前没有任何工作复制变更,或者它们也会被承诺(未进行的变更不会被承诺)。

git push <remote> <branch> --force
# Or
git push <remote> <branch> -f


// n is the number of commits up to the last commit you want to be able to edit
git rebase -i HEAD~n

一旦你错过了你的承诺,选择e/r来编辑消息:

如果你使用 git rebase -i HEAD~n 可以有更多的 n 命令. Git 将“收集”最后 n 命令中的所有命令,如果在这个范围之间有某个合并,你会看到所有的命令,所以结果将是 n + 。

好提示:


git-commit(1) 手动 页 git-rebase(1) 手动 页 git-push(1) 手动 页