How to configure gedit as git core.editor?

2019-03-17 22:18发布

I have gedit configured as 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.

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):

$ 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

标签: git gedit
2条回答
来,给爷笑一个
2楼-- · 2019-03-17 22:53

All credit to VonC answer, but the -w makes gedit (3.18) crash on my ubuntu 16.04. Works fine without though:

git config --global core.editor "gedit -s"
查看更多
Luminary・发光体
3楼-- · 2019-03-17 22:57

The simplest way to solve this would be to upgrade gedit (which is at 3.8.3 with an Ubuntu 13.10)

In 3.x, -s (standalone) and -w (wait) are available.
That allows for (as commented by Fortisimo):

git config --global core.editor "gedit -w -s" 

As Gábor Lipták comments below, this works with gedit3, which is installed with:

sudo apt-get install gedit-common/trusty 
sudo apt-get install gedit/trusty

(on Linux Mint)

查看更多
登录 后发表回答