git - 在 vim 中使用 git commit -a

标签 git vim

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

"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."

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

最佳答案

  1. 在 vim 中,在正常模式下使用 :wEnter 保存文件(按 < 进入正常模式kbd>Esc).
  2. 您在正常模式下使用 :q 关闭文件。

您可以组合这两个操作并执行 Esc:wqEnter 保存提交并退出 vim。

作为上述方法的替代方法,您也可以在正常模式下按 ZZ,这将保存文件并退出 vim。这对某些人来说也更容易,因为它是按两次相同的键。

关于git - 在 vim 中使用 git commit -a,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6098742/

相关文章:

git - 存储库中的全局 .gitignore 与 .gitignore

node.js - Bower - 为已注册的包提供不同的路径

git - 在 fugitive.vim 冲突差异中显示基础

Vim YouCompleteMe c++17 : warning on decomposition declaration

vim - 在vim脚本中返回findfile的驱动器号?

vim - 几个vim问题

git - 在 git 中忽略文件的正确方法是什么?

git - 版本控制 : from zip to git

Git 不询问用户名

vim - 如何在Vim中计算搜索结果?