如何将gedit配置为git core.editor?

Dem*_*myn 21 git gedit

我有gedit配置为git core.editor.

git config --global core.editor "gedit"
Run Code Online (Sandbox Code Playgroud)

除非已打开gedit窗口,否则此工作正常.在这种情况下,COMMIT_EDITMSG在现有窗口中打开,gedit立即返回.Git以空提交消息结束并失败.

这个网站(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
Run Code Online (Sandbox Code Playgroud)

Von*_*onC 22

解决这个问题的最简单方法是升级gedit(使用Ubuntu 13.10时为3.8.3)

在3.x中,-s(独立)和-w(等待)可用.
这允许(如评论Fortisimo):

git config --global core.editor "gedit -w -s" 
Run Code Online (Sandbox Code Playgroud)

作为GABORLipták评论下方,这一点也适用gedit3,它安装有:

sudo apt-get install gedit-common/trusty 
sudo apt-get install gedit/trusty
Run Code Online (Sandbox Code Playgroud)

(在Linux Mint上)

  • 从我的测试来看,只需要`-s`. (2认同)

Arn*_*d P 20

所有归功于VonC的回答,但是-wmake gedit(3.18)在我的ubuntu 16.04上崩溃了.尽管如此工作正常:

git config --global core.editor "gedit -s"
Run Code Online (Sandbox Code Playgroud)

  • 只有当你结合 -w 和 -s 时它才会崩溃。-w 和 -s 在独立使用时都有效。但似乎 -s 意味着 -w ... (2认同)