使用git commit -a和vim [英] Using git commit -a with vim

查看:100
本文介绍了使用git commit -a和vim的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是git的新手,所以我决定使用github的教程学习git。第三章说:


对于第一个例子,我们将修改自述文件以将自己添加为项目中的作者。我们只需编辑文件,现在我们要提交这个改变,所以我们运行 git commit -a 命令。


当我使用 git commit -a 命令时,控制台打开一个vim,我写了我的消息,但是我没有知道如何从控制台关闭这个vim编辑器。如何保存消息并关闭vim?

解决方案


  1. 在vim中,在正常模式下(通过按 Esc 进入正常模式) w Enter li>
  2. 您在正常模式下使用 q 关闭文件。
    $ b

    您可以合并这两个操作并执行 Esc w q < kbd> Enter 保存提交并退出vim。



    作为上述替代方法,您也可以按 Z < kbd> Z ,而在正常模式下,它将保存文件并退出vim。这对于一些人来说也更容易,因为它是同一个按键的两倍。


    I'm new with git, so I decided to learn git using the tutorials of github. The third chapter said:

    "For this first example we’ll modify the README file to add ourselves as an author on the project. So we simply edit the file. Now we want to commit that change, so we run the git commit -a command."

    When I use the git commit -a command, the console opens a vim and I wrote my message, but I don't know how to close this vim editor from the console. How do I save the message and close vim?

    解决方案

    1. In vim, you save a file with :wEnter while in the normal mode (you get to the normal mode by pressing Esc).
    2. You close your file with :q while in the normal mode.

    You can combine both these actions and do Esc:wqEnter to save the commit and quit vim.

    As an alternate to the above, you can also press ZZ while in the normal mode, which will save the file and exit vim. This is also easier for some people as it's the same key pressed twice.

    这篇关于使用git commit -a和vim的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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