git commit --amend 不要求消息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15479609/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git commit --amend without asking for message
提问by talles
From time to time I find myself commit-amendingusing the same message.
有时我发现自己使用相同的消息进行提交修改。
Typically, I do:
通常,我这样做:
- Add my changes to staging area.
- Do
git commit --amend
. - Wait for the text editor to open.
- Save and close it (without changing the message).
- 将我的更改添加到暂存区。
- 做
git commit --amend
。 - 等待文本编辑器打开。
- 保存并关闭它(不更改消息)。
There is anyway to tell git that I don't want to change the commit message (skipping the step of opening my text editor and saving the message)? Like:
无论如何要告诉 git 我不想更改提交消息(跳过打开文本编辑器并保存消息的步骤)?喜欢:
- Add my changes to staging area.
- Tell git to amend my staging area to the last commit without asking me for another message.
- 将我的更改添加到暂存区。
- 告诉 git 将我的暂存区修改为最后一次提交,而不要求我提供另一条消息。
I know I can avoid git firing up my text editor by doing git commit --amend -m "<message>"
. But this way I would have to retype the message.
我知道我可以通过执行 .gitignore 来避免 git 启动我的文本编辑器git commit --amend -m "<message>"
。但是这样我就必须重新输入消息。
回答by Rob Bajorek
Try git commit --amend --no-edit
.
试试git commit --amend --no-edit
。
回答by gylaz
This will amend the latest commit, using that same message, in one command:
这将在一个命令中使用相同的消息修改最新的提交:
git commit --amend -C HEAD