您的位置:首页 > 其它

Git 使用 Sublime Text 为默认编辑器

2015-09-06 11:29 791 查看

Git 使用 Sublime Text 为默认编辑器

首先, 我的 sublime text 的完整路径为:

F:\Program Files\Sublime Text 3\sublime text.exe


(注意
sublime text.exe
名字中没有下划线)

接下来是步骤:

1. 将
F:\Program Files\Sublime Text 3\
添加到 环境变量 中;(之后可能需要重启电脑使更改生效)

2. 打开 git,设置 sublime text 为默认的编辑器, 使用如下命令:

git config
--
global core.editor “‘sublime text.exe’ -w”

此处注意:

如果路径中有空格, 需要用 单引号 括起来, 如上面的

'sublime text.exe'
;

-w 表示 ask git to wait for you to finish typing the message in the text editor

参考资料: 让 EmEditor 成为 Git 的编辑器 看第三楼的回答

3. 验证有没有效果:
git commit -a
, 之后 sublime text 会被打开,

同时一个名为
COMMIT_EDITMSG
文件也会被打开, 嗯, 就是如此。

4. 但输出完成后必须关闭 sublime text,否则 Git 无法完成提交。

参考资料

让 EmEditor 成为 Git 的编辑器

Git使用sublime_text作用默认编辑器

CMD命令行中,文件名有空格怎么输入?

如何在命令行运行程序?看 26 楼

使用git管理源码之修改默认编辑器

补充

做过如下尝试:

1.
git config --global core.editor "sublime text.exe"
(失败)

2.
git config --global core.editor "F:/Program Files/Sublime Text 3/sublime text.exe"
(失败)

3.
git config --global core.editor "'F:/Program Files/Sublime Text 3/sublime text.exe' -w"
(失败)

4.
git config --global core.editor "'sublime text.exe' -w"
(成功)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  sublimetext git 编辑器