如何将 gedit 配置为 git core.editor?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19455929/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to configure gedit as git core.editor?
提问by Demyn
I have gedit configured as git core.editor.
我已将 gedit 配置为 git core.editor。
git config --global core.editor "gedit"
This works fine unless there is already a gedit windows open. In that case, COMMIT_EDITMSG is opened in the existing window and gedit returns immediately. Git ends up with an empty commit message and fails.
除非已经打开了 gedit 窗口,否则这可以正常工作。在这种情况下,COMMIT_EDITMSG 在现有窗口中打开,gedit 立即返回。Git 以一条空的提交消息结束并失败。
This site (http://fabianschuiki.wordpress.com/2012/05/20/use-gedit-as-git-editor/) suggests using "gedit -s -w", but I don't have those options (and --new-window doesn't work):
这个网站(http://fabianschuiki.wordpress.com/2012/05/20/use-gedit-as-git-editor/)建议使用“gedit -s -w”,但我没有这些选项(和--new-window 不起作用):
$ gedit -V
gedit - Version 2.28.4
$ gedit --help
Usage:
gedit [OPTION...] [FILE...] - Edit text files
Help Options:
-h, --help Show help options
--help-all Show all help options
--help-gtk Show GTK+ Options
--help-sm-client Show session management options
Application Options:
-V, --version Show the application's version
--encoding=ENCODING Set the character encoding to be used to open the files listed on the command line
--list-encodings Display list of possible values for the encoding option
--new-window Create a new toplevel window in an existing instance of gedit
--new-document Create a new document in an existing instance of gedit
--display=DISPLAY X display to use
回答by VonC
The simplest way to solve this would be to upgrade gedit(which is at 3.8.3 with an Ubuntu 13.10)
解决此问题的最简单方法是升级gedit(使用 Ubuntu 13.10升级至 3.8.3)
In 3.x, -s(standalone) and -w(wait) are available.
That allows for (as commentedby Fortisimo):
在 3.x 中,-s(standalone) 和-w(wait) 可用。
这允许(如评论由Fortisimo):
git config --global core.editor "gedit -w -s"
As Gábor Liptákcomments below, this works with gedit3, which is installed with:
正如Gábor Lipták在下面评论的那样,这适用于 gedit3,它安装了:
sudo apt-get install gedit-common/trusty
sudo apt-get install gedit/trusty
(on Linux Mint)
(在 Linux Mint 上)
回答by Arnaud P
All credit to VonC answer, but the -wmakes gedit (3.18) crash on my ubuntu 16.04. Works fine without though:
全部归功于 VonC 的回答,但-w使 gedit (3.18) 在我的 ubuntu 16.04 上崩溃。工作正常,但没有:
git config --global core.editor "gedit -s"

