git使用emacs作为Windows下的编辑器进行提交

Gau*_*ier 5 windows git emacs

在Windows中使用git bash,我将我设置core.editor为以下内容:

 c:/program/emacs-24.2/bin/emacs --no-splash -geometry 110x58+200+2
Run Code Online (Sandbox Code Playgroud)

git commit,新的emacs框架按预期打开.打开的缓冲区有$@一个名称.我无法保存缓冲区并退出emacs.Git抱怨提交消息为空.

我有一个解决方法,即将我设置core.editor为:

c:/program/emacs-24.2/bin/emacs --no-splash -geometry 110x58+200+2 .git/COMMIT_EDITMSG
Run Code Online (Sandbox Code Playgroud)

这有效,但有一些缺点:

  • 我必须在包含.git文件夹的目录中.如果我在子目录中,它不起作用.
  • 打开的emacs框架有两个窗口,一个带有COMMIT_EDITMSG,一个带有$@.

有没有更好的方法来选择emacs作为提交编辑器(除了在终端中打开它)?

sds*_*sds 5

我建议你

  • 将Emacs作为守护进程运行 - 但显然是unix-only,或者
  • Emacs像往常一样运行并使用M-x server-start RET或添加(server-start)到服务器.emacs

并使用emacsclient,而不是emacs作为你的core.editor,如果你坚持跑步git(命中命令行C-x #完成编辑通过控制回当客户端缓存git).

然而,用最好的方式Emacsgitvc:

Emacs,键入C-x v d your/git/repo/root/dir RET以获取已修改文件的列表,标记要提交的文件,m键入C-x v v以提交它们 - 显示提交消息的缓冲区(使用ChangeLog条目为您初始化,如果有),编辑它,键入C-c C-c并且您是完成.