如何退出 Git 中的文本窗口?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9171356/
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
How do I exit from the text window in Git?
提问by newbie
I am using Windows and before committing, Git wants me to enter a text message and a new text window appears.
我使用的是 Windows,在提交之前,Git 要我输入一条文本消息并出现一个新的文本窗口。
How can I exit from this?
我该如何退出?
I am trying to learn Git. So, a little help will be highly appreciated.
我正在努力学习 Git。因此,我们将不胜感激。
回答by manojlds
Since you are learning Git, know that this has little to do with git but with the text editor configured for use. In vim, you can press i
to start entering text and save by pressing esc
and :wq
and enter
, this will commit with the message you typed. In your current state, to just come out without committing, you can do :q
instead of the :wq
as mentioned above.
由于您正在学习 Git,请知道这与 git 无关,而是与配置使用的文本编辑器有关。在vim,您可以按i
开始输入文字,然后按下保存esc
和:wq
和enter
,这将与您输入的信息提交。在你目前的状态下,为了不承诺就出来,你可以:q
代替:wq
上面提到的。
Alternatively, you can just do git commit -m '<message>'
instead of having git open the editor to type the message.
或者,您可以直接执行git commit -m '<message>'
而不是让 git 打开编辑器来输入消息。
Note that you can also change the editor and use something you are comfortable with ( like notepad) - How can I set up an editor to work with Git on Windows?
请注意,您还可以更改编辑器并使用您喜欢的东西(例如记事本) -如何设置编辑器以在 Windows 上使用 Git?
回答by Johnsyweb
There is a default text editorthat will be used when Git needs you to type in a message. By default, Git uses your system's default editor, which is generally Vior Vim. In your case, it is Vim that Git has chosen. See How do I make Git use the editor of my choice for commits?for details of how to choose another editor. Meanwhile...
有一个默认的文本编辑器时的Git需要你在邮件中键入将被使用。默认情况下,Git 使用您系统的默认编辑器,通常是Vi或Vim。在您的情况下,Git 选择了 Vim。请参阅如何让 Git 使用我选择的编辑器进行提交?有关如何选择其他编辑器的详细信息。同时...
You'll want to enter a message before you leave Vim:
在离开Vim之前,您需要输入一条消息:
...will start a new line for you to type in.
...将开始一个新行供您输入。
To exit (g)Vim type:
退出 (g)Vim 输入:
It's worth getting to know Vim, as you can use it for editing text on almost any platform. I recommend the Vim Tutor
, I used it manyyears ago and have never looked back (barely a day goes by when I don't use Vim).
了解 Vim 是值得的,因为您几乎可以使用它在任何平台上编辑文本。我推荐的Vim Tutor
,我用它很多年以前,从来没有回头(几乎每天都会当我不使用VIM)。
回答by Arlan T
On Windows 10 this worked for me for VIM and VI using git bash
在 Windows 10 上,这对我使用 git bash 对 VIM 和 VI 有用
"Esc" + ":wq!"
or
或者
"Esc" + ":q!"
回答by Riya Abraham
On windows I used the following command
在 Windows 上,我使用了以下命令
:wq
and it aborts the previous commit because of the empty commit message
并且由于空的提交消息而中止先前的提交
回答by Abhinav Saxena
On windows, simply pressing 'q' on the keyboard quits this screen. I got it when I was reading help using '!help' or simply 'help' and 'enter', from the DOS prompt.
在 Windows 上,只需按键盘上的“q”即可退出此屏幕。当我在 DOS 提示符下使用 '!help' 或简单地使用 'help' 和 'enter' 阅读帮助时,我得到了它。
Happy Coding :-)
快乐编码:-)