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

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

问题描述

我在使用 git 将 Sublime Text 2 设置为 core.editor 时遇到问题.

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

我已经通读了我能找到的所有解决问题的帖子,但仍然没有任何内容对我有用.我运行的是 Windows.

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

我已经完成了:

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(内部版本 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(内部版本 3065)

Sublime Text 3(版本 3065)添加了 subl.exe 命令线帮手.将 subl.exe -h 用于您可用的选项.我在我的 Sublime Text 用户设置中设置了 hot_exit: trueremember_open_files: true .我发现以下 git config 对我来说很有效.

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.editor "subl -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天全站免登陆