我在承诺信中写错了。

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


当前回答

我添加了 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 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) 手动 页

我喜欢使用以下内容:

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

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

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-rebase-reword

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

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

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

例子:

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