[英]git commit with emacs as editor under Windows
Using git bash in Windows, I set my core.editor
to the following:在 Windows 中使用 git bash,我将
core.editor
设置为以下内容:
c:/program/emacs-24.2/bin/emacs --no-splash -geometry 110x58+200+2
Upon git commit
, a new emacs frame opens as expected. git commit
git 后,将按预期打开一个新的 emacs 框架。 The opened buffer has $@
as a name.打开的缓冲区以
$@
作为名称。 I cannot save the buffer and exit emacs. Git complains that the commit message was empty.我无法保存缓冲区并退出 emacs。Git 抱怨提交消息为空。
I have a workaround, which is to set my core.editor
to:我有一个解决方法,
core.editor
设置为:
c:/program/emacs-24.2/bin/emacs --no-splash -geometry 110x58+200+2 .git/COMMIT_EDITMSG
This works, but with a couple of drawbacks:这可行,但有几个缺点:
COMMIT_EDITMSG
, one with $@
.COMMIT_EDITMSG
,一个带有$@
。 Is there a better way to choose emacs as commit editor (besides making it open in the terminal)?有没有更好的方法来选择 emacs 作为提交编辑器(除了在终端中打开它之外)?
I suggest that you either 我建议你
Emacs
as usual and start the server with Mx server-start RET
or add (server-start)
to .emacs
Emacs
并使用Mx server-start RET
或将(server-start)
添加到.emacs
and use emacsclient
instead of emacs
as your core.editor
if you insist on running git
from the command line (hit Cx # in the client buffer when done editing to pass the control back to git
). 如果你坚持从命令行运行
git
,那么使用emacsclient
而不是emacs
作为你的core.editor
(在完成编辑后,在客户端缓冲区中点击Cx#将控制权传回git
)。
However, the best way to use Emacs
with git
is vc
: 但是,使用
git
使用Emacs
的最佳方法是vc
:
In Emacs
, type Cx vd your/git/repo/root/dir RET to get the list of modified files, mark those you want to commit with m , type Cx vv to commit them - a buffer for the commit message appears (initialized for you with the ChangeLog
entry, if any), edit it, type Cc Cc and you are done. 在
Emacs
,键入Cx vd your / git / repo / root / dir RET以获取已修改文件的列表,标记要使用m提交的文件,键入Cx vv以提交它们 - 将显示提交消息的缓冲区(已初始化为你使用ChangeLog
条目(如果有的话),编辑它,键入Cc Cc ,你就完成了。
Another very nice interface to git
within emacs is provided by magit
. magit
提供了另一个非常好的emacs内git
接口。 The idea behind magit
is to provide you with an interactive interface within emacs to easily run all the frequently used git commands, essentially eliminating the need for you to directly run git
from the commands-line. magit
背后的想法是在emacs中为您提供一个交互式界面,以便轻松运行所有常用的git命令,从而基本上无需您从命令行直接运行git
。
Although it is not standard (unlike vc
, which was mentioned in another answer), you can install it very simply using the packaging system, for example from the melpa or marmalade repositories. 虽然它不是标准的(与另一个答案中提到的
vc
不同),但您可以使用包装系统非常简单地安装它,例如从melpa或marmalade存储库中安装。
This works for me under msysgit 1.7.11: 这在msysgit 1.7.11下适合我:
git config core.editor '/d/bin/emacs-24.3/bin/emacs.exe'
but when I switched to this: 但是当我切换到这个:
git config core.editor '/d/bin/emacs-24.3/bin/emacs.exe --no-splash'
I got the same '$@' buffer as you do. 我和你一样有'$ @'缓冲区。
Nothing I found online worked the way I wanted, and surprisingly I did not see this command yet..so, here is how I made emacs work in Git for windows:我在网上找到的任何东西都没有按照我想要的方式工作,令人惊讶的是我还没有看到这个命令..所以,这是我如何让 emacs 在 Git 中为 windows 工作:
git config --global core.editor "'C:\Program Files\Emacs\x86_64\bin\runemacs.exe' -wait"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.