将 sublimetext 3 设置为 git commit 文本编辑器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22631863/
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
Setting up sublimetext 3 as git commit text editor
提问by Alan Quigley
I'm having trouble setting up sublime as my git commit message editor.
我在将 sublime 设置为我的 git commit 消息编辑器时遇到问题。
Using:
使用:
git config --global core.editor "subl"
Error: error: cannot run subl: No such file or directory error: unable to start editor 'subl' Please supply the message using either -m or -F option.
错误:错误:无法运行 subl:没有此类文件或目录错误:无法启动编辑器 'subl' 请使用 -m 或 -F 选项提供消息。
subl work perfectly otherwise.
否则 subl 工作得很好。
回答by 2540625
For what it's worth, here's how I solved it:
对于它的价值,这是我解决它的方法:
1) Run in Terminal:
1)在终端运行:
sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
This adds a subl
alias to /usr/local/bin/
pointing to Sublime Text 3 app's binary file. Now running subl
in Terminal will launch Sublime Text 3 app.
这会添加一个subl
别名以/usr/local/bin/
指向 Sublime Text 3 应用程序的二进制文件。现在subl
在终端中运行将启动 Sublime Text 3 应用程序。
2) Run in Terminal:
2)在终端运行:
git config --global core.editor "subl -n -w"
This adds editor = subl -n -w
to the [core]
section of the ~/.gitconfig
file. Now running git commit
in Terminal will launch Sublime Text 3 app (subl
) in a new window (-n
), and the command line will wait (-w
) until the commit message is saved andclosed.
这将添加editor = subl -n -w
到文件的[core]
部分~/.gitconfig
。现在git commit
在终端中运行将subl
在新窗口 ( -n
) 中启动 Sublime Text 3 应用程序 ( ),命令行将等待 ( -w
) 直到提交消息被保存并关闭。
Image of final workflow added in response to clarifying question in comments below:
为回应以下评论中的澄清问题而添加的最终工作流程图像:
Official Sublime Text 3 doc: http://www.sublimetext.com/docs/3/osx_command_line.html
官方 Sublime Text 3 文档:http: //www.sublimetext.com/docs/3/osx_command_line.html
回答by Dani?l W. Crompton
You can solve this by putting in a full path
您可以通过放置完整路径来解决此问题
git config --global core.editor "/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -n -w"
Source: OS X Command Line
来源:OS X 命令行
EDIT: If the name of the app is not Sublime Text.app
you will want to replace that with the correct name.
编辑:如果应用程序的名称不是,Sublime Text.app
您需要用正确的名称替换它。
回答by Anmol Saraf
Sublime Text 2
崇高的文字 2
git config --global core.editor "'c:/program files/sublime text 2/sublime_text.exe' -n -w"
Sublime Text 3( Tested this on my Windows 10 MS Surface Pro 3 )
Sublime Text 3 (在我的 Windows 10 MS Surface Pro 3 上测试过)
git config --global core.editor "'C:/Program Files/Sublime Text 3/subl.exe' -n -w"
You can also add following line to your .gitconfig file
您还可以将以下行添加到您的 .gitconfig 文件中
[core]
editor = "'C:/Program Files/Sublime Text 3/subl.exe' -n -w"
Hope it helps.
希望能帮助到你。
回答by N. Osil
I found out that I receive messages like:
我发现我收到如下消息:
subl -n -w: subl: command not found.
subl -n -w: subl: command not found.
error: There was a problem with the editor 'subl -n -w'
error: There was a problem with the editor 'subl -n -w'
error: There was a problem with the editor 'subl'
error: There was a problem with the editor 'subl'
even though Sublime works well and can be launched from Terminal.
即使 Sublime 运行良好并且可以从终端启动。
To fix it, run the following in Terminal:
要修复它,请在终端中运行以下命令:
git config --global core.editor " 'XXXXX' -n -w"
while 'XXXXX' is the path which Sublime is launched from.
而 'XXXXX' 是 Sublime 的启动路径。
It could be /usr/bin/subl
as Pranav Misra mentioned, or /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl
, or whatever you put in the symlink you have created.
它可以是/usr/bin/subl
Pranav Misra 提到的,或者 /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl
,或者你在你创建的符号链接中放置的任何内容。
回答by Pranav Misra
I'm new to the community, and apologize if the answer is not in the proper format.
For me the following things worked for Sublime 3 git config --global core.editor " '/usr/bin/subl' -n -w"
Thank you all.
我是社区的新手,如果答案格式不正确,我深表歉意。对我来说,以下内容适用于 Sublime 3git config --global core.editor " '/usr/bin/subl' -n -w"
谢谢大家。
回答by Ankit kaushik
To add sublime Text as the default text editor , first create a symlink :
要将 sublime Text 添加为默认文本编辑器,首先创建一个符号链接:
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl
Also , make it the default editor for any time when input is asked by
此外,在任何时候询问输入时,将其设为默认编辑器
export EDITOR='subl -w'
Finally ,
最后 ,
git config --global core.editor "subl -n -w"
回答by domoarigato
I tried all of these answers, but nothing worked. ~/.gitconfig showed that sublime was set, but git wouldn't pick up the change. In the end, I restarted my macbook, and that did it. srsly.
我尝试了所有这些答案,但没有任何效果。~/.gitconfig 显示 sublime 已设置,但 git 不会接受更改。最后,我重新启动了我的 macbook,它做到了。亲爱的。
git config --global core.editor "subl -n -w"
git config --global core.editor "subl -n -w"