如何使用vim添加提交消息? [英] How to add commit message using vim?

查看:55
本文介绍了如何使用vim添加提交消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试了解有关Git的更多信息,并从绝对的基础知识继续学习,这是我现在所拥有的全部.我希望能够使用vim(或nano,或任何其他文本编辑器)添加提交消息,而不是将所有日志消息都放在命令行中.谁能一步一步告诉我我该怎么做?

Trying to learn more about Git and to move on from absolute basics which is all I have right now. I want to be able to add a commit message using vim (or nano, or any other text editor) rather than putting all of the log message on the command line. Can anyone tell me step by step how I can do this?

推荐答案

这主要是有关使用VIM的问题,让我们开始吧.

This is mostly a question about using VIM, so let's to it.

首先,如果不是默认设置,则需要设置Git以使用Vim作为编辑器.您可以通过添加到您选择的git配置中来做到这一点(本地,-global -system 都不是):git config --global core.editor vim

First, you need to setup Git to use Vim as the editor, if that's not the default for you. You can do that by adding to the git config of your choice (none which is local, --global or --system): git config --global core.editor vim

然后在提交时,无需添加 -m 参数,请将其保留为空白:git提交//或者git commit -a

Then when you commit, you don't add the -m parameter, leave it blank: git commit // or git commit -a

之后,您以退出模式进入VIM.然后,您需要启动插入模式进行写入.最简单的方法是键入 i ,然后在底部显示一条消息(-INSERT-).您处于插入模式,现在可以输入消息.

After that, you are in VIM, in escape mode. You then need to start insert mode to write. The simplest way is to type i, and a message will appear on the bottom (-- INSERT --). You are in insert mode and you can now type in your message.

此后,必须退出插入模式,然后按一次 Esc 即可.底部的-INSERT-消息应消失.您现在再次处于逃生模式,必须保存并退出.

After that, you must exit insert mode, and you do that by pressing Esc once. The -- INSERT -- message on the bottom should vanish. You are now in escape mode again, and you must save and quit.

这是通过使用:键进入命令模式并键入命令 wq x 来完成的,剩下的要么是在底部键入>:wq :x .

That is done by using the : key to enter command mode and typing the command wq or x, leaving you with either :wq or :x typed at the bottom.

w 代表写入,而 q 代表退出,所以 wq 是写入和退出. x wq 的别名.

w stands for write and q for quit, so wq is write and quit. x is an alias for wq.

此后,您只需按 Enter ,即可完成VIM之外的操作.

After that you just press Enter and you're done, out of VIM.

如果您有任何疑问,请发表评论,我会加起来.

If you have any doubts post a comment and I'll add it up.

这篇关于如何使用vim添加提交消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆