简体   繁体   English

外部编辑器中的git --amend

[英]git --amend in external editor

I am working on learning how to use git and the section I am on now is using --amend. 我正在学习如何使用git,而我现在正在使用的部分是--amend。 When I run this in terminal it opens up TextMate for me to change the message. 当我在终端中运行它时,它打开TextMate让我改变消息。 I change the message and then save. 我更改了消息然后保存。 I go back to terminal and nothing has happened. 我回到终点站,什么也没发生。

What step am I missing here or am I not doing this correct? 我在这里错过了什么步骤,还是我没有这样做?

You have to set the --wait (-w) flag in your git configuration. 您必须在git配置中设置--wait (-w)标志。 Thus you can type text in your editor and git will wait for the save/close event. 因此,您可以在编辑器中键入文本,git将等待save / close事件。 For TextMate something like this should work: 对于TextMate,这样的东西应该工作:

git config --global core.editor "mate -w"

The text editor which you use should not "spawn off" and return control to git until you save and quit it. 您使用的文本编辑器不应“生成”并将控制权返回给git,直到您保存并退出它为止。 I don't know how to configure textmate to work in this fashion but if you set your EDITOR variable to something like vim , you should be able to see it work fine. 我不知道如何配置textmate以这种方式工作,但如果你将EDITOR变量设置为像vim这样的东西,你应该能够看到它正常工作。 When you run your command, it will spawn the editor and ask you to make changes. 当您运行命令时,它将生成编辑器并要求您进行更改。 When you do so and quit, the git command will continue running and amend your commit. 当你这样做并退出时,git命令将继续运行并修改你的提交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM