Git Emacs shell:保存提交消息

Git Emacs shell:保存提交消息,git,shell,vim,emacs,Git,Shell,Vim,Emacs,我几天前开始使用emacs,在emacs shell(m-x shell)中使用git时遇到了一个问题。当我输入'git commit'或'git commit--amend'时,它会打开vim来编辑和保存提交消息。我同意,但我找不到保存和退出vim的方法,因为点击ESC不会触发vim正常模式,ESC是我的emacs元键。 我尝试将我的git编辑器更改为emacs,但它也不起作用,看起来emacs shell无法运行emacs,而且它也没有像我想象的那样打开新的缓冲区 emacs: Termin

我几天前开始使用emacs,在emacs shell(m-x shell)中使用git时遇到了一个问题。当我输入'git commit'或'git commit--amend'时,它会打开vim来编辑和保存提交消息。我同意,但我找不到保存和退出vim的方法,因为点击ESC不会触发vim正常模式,ESC是我的emacs元键。 我尝试将我的git编辑器更改为emacs,但它也不起作用,看起来emacs shell无法运行emacs,而且它也没有像我想象的那样打开新的缓冲区

emacs: Terminal type "dumb" is not powerful enough to run Emacs.
有没有一种方法可以在emacsshell中使用git命令行(我不想使用git前端客户端,比如magit,…)呢

谢谢,
Robin

您可以使用

git config core.editor nano
或者,您可以将消息放在命令行上,使其无法打开任何编辑器:

git commit --amend -m "My message"

在评论中发布@romainl的答案,因为它符合我的要求:
要退出插入模式,
:wq
:x
并输入。

另一种方法是使用gits功能将文件用作提交消息:

  • 在提交之前,将提交消息(在emacs中)写入临时文件
  • 提交方式:git commit-F temp_文件名
  • 删除文件

  • 看起来我也无法用C-x关闭nano。它会触发emacs命令。顺便说一句,我在操作系统X上,不知道这是否有关系。C-X C-X应该向nano发送一个实际的C-X。你可以使用
    为一个命令退出插入模式,所以
    :wq
    :X
    ZZ
    应该可以做到。是的,确实如此。谢谢