Spe*_*ran 210 git default editor git-config sublimetext
我将Sublime Text 2设置为core.editorwith时遇到问题git.
我已经阅读了我能找到解决问题的每一篇文章,但仍然没有任何对我有用.我正在运行Windows.
我已经做好了:
git config --global core.editor "'C:/Program Files/Sublime Text 2/sublime_text.exe'"
Run Code Online (Sandbox Code Playgroud)
并尝试过各种各样的论点-m.当我打开我的时候.gitconfig,这就是那里的东西:
[user]
name = Spencer Moran
email = smoran02@gmail.com
[core]
editor = 'C:/Program Files/Sublime Text 2/sublime_text.exe'
Run Code Online (Sandbox Code Playgroud)
如果我去Git并输入:
README.markdown --edit
Run Code Online (Sandbox Code Playgroud)
README文件在记事本中打开,而不是Sublime Text.
有谁知道我做错了什么或我怎么解决这个问题?
jro*_*llo 334
最新的Build 2181刚刚添加了对-w(wait)命令行参数的支持.以下配置将允许ST2作为Windows上的默认git编辑器.这将允许git为提交消息等打开ST2.
git config --global core.editor "'c:/program files/sublime text 2/sublime_text.exe' -w"
Run Code Online (Sandbox Code Playgroud)
Sublime Text 3(Build 3065)添加了subl.exe命令行助手.subl.exe -h用于您可以使用的选项.我hot_exit: true和remember_open_files: true我的崇高文字使用者设定.我发现以下git配置适合我.
git config --global core.editor "'c:/program files/sublime text 3/subl.exe' -w"
Run Code Online (Sandbox Code Playgroud)
通过在终端中键入以下命令,将Sublime设置为Git的编辑器:
git config --global core.editor "subl -n -w"
使用此Git配置,新选项卡将在我的编辑器中打开.我编辑提交消息,保存选项卡(Ctrl+ S)并关闭它(Ctrl+ W).
Git将一直等到标签关闭才能继续工作.
小智 93
您可以在Mac和Linux上使用此命令:
git config --global core.editor "subl -n -w"
Run Code Online (Sandbox Code Playgroud)
Ahm*_*ais 14
对于[core]下的〜/ .gitconfig文件中的Mac OS X,我不得不把这段代码放在我的头上解决问题.
editor = /Applications/Sublime\\ Text.app/Contents/SharedSupport/bin/subl -n -w
Run Code Online (Sandbox Code Playgroud)
这是当subl工作正常但git无法访问它.并显示这些错误
subl -n -w: subl: command not found
error: There was a problem with the editor 'subl -n -w'.
Run Code Online (Sandbox Code Playgroud)
小智 9
对于Mac和Sublime Text 3:
如果git config --global core.editor "subl -n -w"不起作用,请使用以下git config命令:
$ git config --global core.editor "'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl' -n -w"
Run Code Online (Sandbox Code Playgroud)
注意:它不包含逃避反斜杠.
在cygwin/zsh中对我有用的东西:
在/ usr/local/bin中创建subl_git文件
#!/bin/bash
/cygdrive/c/Program\ Files/Sublime\ Text\ 2/sublime_text.exe -w -n `cygpath -w $@`
Run Code Online (Sandbox Code Playgroud)
在gitconfig中:
editor = /usr/local/bin/subl_git
Run Code Online (Sandbox Code Playgroud)
使用Sublime Text 2和以下配置,如果关闭git commit的注释文件时没有任何反应:
git config --global core.editor "'c:/program files/sublime text 2/sublime_text.exe' -w"
Run Code Online (Sandbox Code Playgroud)
如果在Sublime中关闭COMMIT_EDITMSG注释文件时git commit没有完成,我发现这可能是因为你在管理员模式下运行CMD(并且已经在非管理模式下打开了Sublime Text).我遇到了同样的问题,当我以正常模式启动CMD时,它对我有用.
Ps:只是想回答@david在接受的答案评论中指出的问题,但我不能发表评论,因为我是新来的......所以我做了一个新答案,因为我认为这可以是对遇到问题的人有用.
我刚刚在PowerShell的帮助下成功完成了它(用于Windows的命令行工具,它也可以用作GithubforWindows上的默认命令行)
只需在"C:\ Users \%username%\ My Documents"上创建一个文件夹"WindowsPowerShell".然后,创建一个名为"profile.ps1"的文件.确保您具有正确的文件扩展名,.ps1而不是.txt.在profile.ps1中,将此行设置为别名命令:
Set-Alias subl 'c:\program files\sublime text 2\sublime_text.exe'
Run Code Online (Sandbox Code Playgroud)
确保计算机上的sublime目录正确无误.您还可以在此处查看配置详细信息.
现在,我只需键入以下内容,即可通过PowerShell命令使用Sublime Text 2编辑文件:
subl filename
Run Code Online (Sandbox Code Playgroud)
希望这很有用......