我在承诺信中写错了。
我怎么能改變訊息呢?承諾尚未推動。
我在承诺信中写错了。
我怎么能改變訊息呢?承諾尚未推動。
当前回答
我添加了 Aliases reci 和 recm for recommit (amend) 它. 现在我可以用 git recm 或 git recm -m:
$ vim ~/.gitconfig
[alias]
......
cm = commit
reci = commit --amend
recm = commit --amend
......
其他回答
您可以使用 git-rebase-reword
它旨在以同样的方式编辑任何承诺(不只是最后) - 修改
$ git rebase-reword <commit-or-refname>
它被命名为反对互动的行动,以改变一个承诺:“反对”。 查看此帖子和人 - 部分互动模式-
例子:
$ git rebase-reword b68f560
$ git rebase-reword HEAD^
更改最新承诺消息
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 filter-branch 为此。
git filter-branch -f --msg-filter "sed 's/errror/error/'" $flawed_commit..HEAD
它不像一个虚假的吉特承诺 - 修正,但它特别有用,如果你已经有一些合并后你的错误的承诺消息。
请注意,这将试图重新写下头部和错误的承诺之间的每一个承诺,所以你应该非常明智地选择你的msg过滤器命令 ;-)
您可以使用 Git 重定向. 例如,如果您想要修改回来承诺 bbc643cd,运行
$ git rebase bbc643cd^ --interactive
在默认编辑器中,修改“选择”到“编辑”的行,您想要修改的承诺。
$ git add <filepattern>
现在你可以使用
$ git commit --amend
要改變承諾,然後
$ git rebase --continue
要回到前任首席执行官。
如果你只想修改你的最后一个承诺消息,那么做: git commit --amend
它会把你推到你的文本编辑器,让你改变最后的承诺消息。
如果您想更改前三個承諾訊息,或任何承諾訊息到這一點,請將 HEAD~3 傳送到 git rebase -i 命令: git rebase -i HEAD~3