使用 Vim 输入 Git 提交消息时出现问题
操作系统:Windows
我
$ git commit
当时
写的“#请输入提交信息”
我写了一些文字,比如
“已添加表单验证”
按 Enter 键且未提交。然后我按 Shift+Enter、Ctrl+Enter、Alt+Enter - 仍然没有提交。
我认为这是愚蠢的麻烦,但我必须做什么?
OS: Windows
I write
$ git commit
then
"# Please enter the commit message"
I write some text, like
"Form validation added"
Press Enter and not commited. Then i press Shift+Enter, Ctrl+Enter, Alt+Enter - still not commited.
I think its stupid trouble, but What i must to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果是 Windows 版 VIM,您可以执行以下操作:
:wq
输入或ZZ
。请注意,在 VIM 中通常有多种方法可以完成一件事。但这里有一点细微的差别。
:wq
Enter 始终在关闭当前文件之前写入当前文件,而ZZ
、:x
Enter< /kbd>,:xi
输入,:xit
输入,:exi
< kbd>Enter 和:exit
Enter 仅在文档修改时才写入。所有这些同义词只是按键次数不同。
If it is VIM for Windows, you can do the following:
:wq
Enter orZZ
.Note that in VIM there are often several ways to do one thing. Here there is a slight difference though.
:wq
Enter always writes the current file before closing it, whileZZ
,:x
Enter,:xi
Enter,:xit
Enter,:exi
Enter and:exit
Enter only write it if the document is modified.All these synonyms just have different numbers of keypresses.
我假设你正在使用 msys git。如果是,则弹出来编写提交消息的编辑器是 vim。 Vim 一开始并不友好。您可能更愿意切换到不同的编辑器。如果您想使用其他编辑器,请查看此答案:如何将 Notepad++(或其他)与 msysgit 一起使用?
如果您想使用 vim,请输入
i
来输入您的消息。高兴的时候按ESC。然后输入:wq
,然后 git 就会高兴了。或者只需输入 git commit -m "your message here" 即可完全跳过编辑器。
I am assuming you are using msys git. If you are, the editor that is popping up to write your commit message is vim. Vim is not friendly at first. You may prefer to switch to a different editor. If you want to use a different editor, look at this answer: How do I use Notepad++ (or other) with msysgit?
If you want to use vim, type
i
to type in your message. When happy hit ESC. Then type:wq
, and git will then be happy.Or just type
git commit -m "your message here"
to skip the editor altogether.你有没有尝试过:
git commit -m "Message here"
所以在你的情况下:
当然是在你添加文件之后。
Have you tried just going:
git commit -m "Message here"
So in your case:
After you've added your files of course.
通常,
git commit
会打开一个交互式编辑器(在 Linux 上,可能还有 Cygwin,由$EDITOR
环境变量的内容决定)供您编辑提交消息保存并退出后,提交完成。您应该确保您尝试提交的更改已添加到 Git 索引中;这决定了所承诺的内容。有关详细信息,请参阅 http://gitref.org/basic/。
Typically,
git commit
brings up an interactive editor (on Linux, and possibly Cygwin, determined by the contents of your$EDITOR
environment variable) for you to edit your commit message in. When you save and exit, the commit completes.You should make sure that the changes you are trying to commit have been added to the Git index; this determines what is committed. See http://gitref.org/basic/ for details on this.
您可以将注释字符更改为 # 以外的字符,如下所示:
You can change the comment character to something besides # like this: