我如何使Sublime Text成为Git的默认编辑器? [英] How can I make Sublime Text the default editor for Git?

查看:177
本文介绍了我如何使Sublime Text成为Git的默认编辑器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,把Sublime Text 2设置为 core.editor ,其中 git

I have a problem setting Sublime Text 2 as the core.editor with git.

我已阅读了所有可以找到解决问题的文章,但仍然没有为我工作。

I've read through every post I could find addressing the problem, but still nothing is working for me. I am running Windows.

我完成了:

I have done:

git config --global core.editor "'C:/Program Files/Sublime Text 2/sublime_text.exe'"



<并用 -m 等各种参数进行尝试。当我打开我的 .gitconfig 时,它就是这样:

and tried that with various arguments like -m. When I open my .gitconfig, this is what is in there:

[user]
    name = Spencer Moran
    email = smoran02@gmail.com
[core]
    editor = 'C:/Program Files/Sublime Text 2/sublime_text.exe'

如果我转到Git并键入:

If I go to Git and type:

README.markdown --edit

README文件打开记事本,而不是Sublime Text。

the README file opens in Notepad, not Sublime Text.

有人知道我做错了什么,或者我可以如何解决这个问题吗?

Does anyone have any idea what I'm doing wrong or how I could fix this?

推荐答案

Windows



Sublime Text 2(Build 2181)



最新的 Build 2181 刚刚添加了支持用于 -w (等待)命令行参数。以下配置将允许ST2在Windows上作为默认的git编辑器。这将允许git打开ST2提交消息等。

Windows

Sublime Text 2 (Build 2181)

The latest Build 2181 just added support for the -w (wait) command line argument. The following configuration will allow ST2 to work as your default git editor on Windows. This will allow git to open ST2 for commit messages and such.

git config --global core.editor "'c:/program files/sublime text 2/sublime_text.exe' -w"



Sublime Text 3(Build 3065)



崇高文字3 (Build 3065)新增 subl.exe 命令行助手。使用 subl.exe -h 作为您可用的选项。我在Sublime Text用户设置中设置了 hot_exit:true remember_open_files:true

Sublime Text 3 (Build 3065)

Sublime Text 3 (Build 3065) added the subl.exe command line helper. Use subl.exe -h for the options available to you. I have hot_exit: true and remember_open_files: true set in my Sublime Text user settings. I have found the following to git config to work well for me.

git config --global core.editor "'c:/program files/sublime text 3/subl.exe' -w"






Mac和Linux



在终端中输入以下命令,设置Sublime作为Git的编辑器:


Mac and Linux

Set Sublime as your editor for Git by typing the following command in the terminal:

git config --global core.editorsubl -n -w

使用此Git配置,新选项卡在我的编辑器中打开。我编辑我的提交信息,保存标签( Ctrl + S )并关闭它( Ctrl + W )。 。

With this Git config, the new tab is opened in my editor. I edit my commit message, save the tab (Ctrl+S) and close it (Ctrl+W).

Git将等到该标签关闭才能继续工作。

Git will wait until the tab is closed to continue its work.

这篇关于我如何使Sublime Text成为Git的默认编辑器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆