20

So I'm trying to set up GitHub for the first time ever and I want Sublime Text to be my core editor, how exactly do I do that? Sorry if this is a noob question, I am a noob :/

CharlesB
  • 86,532
  • 28
  • 194
  • 218
Chris Wildman
  • 203
  • 2
  • 4

4 Answers4

23

As this ranked highly when I was searching Google for Mac instructions, here is a combination of solutions I found.

First I set up a command line utility matching "subl" to Sublime Text from any terminal instance with this terminal command.

sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /bin/subl

Then I do a similar git config command to the Windows solution above, but with a -w parameter at the end.

git config --global core.editor "subl -w"
Ted Avery
  • 5,639
  • 3
  • 30
  • 29
20

Enter this command in a prompt:

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

It will then pop up when prompted for a commit message, or any other edition task, but if it was already open it won't work since it uses the same instance. Don't know how to workaround this.

CharlesB
  • 86,532
  • 28
  • 194
  • 218
  • 3
    The latest build 2181 just added support for the -w (wait) command line argument on Windows. This solves the same instance problem you describe. – jrotello Feb 23 '12 at 06:32
  • 12
    For me, the path need to be additionally single-quoted like this: `git config --global core.editor "'c:/program files/sublime text 2/sublime_text.exe' -w"` – Joe Nov 08 '12 at 17:39
  • Is the '-w' option required? What function does it serve? – Legato May 07 '16 at 21:29
1

Since build 3010 of Sublime Text 3, the subl.exe helper is included by default. So, combining CharlesB and Ted's answers gives you the best answer --

type in a prompt (cmd.exe or git_bash):

setx SUBLIME c:\path\to\sublime\install\dir git config --global core.editor "subl.exe -w"

Note the presence/absence of quotes. git config requires them, whereas setx does NOT. Also, while you're at it, try using a path\to\sublime that doesn't use spaces. That way you can use this with both MSysGit and Cygwin Git.

codeBreath
  • 11
  • 3
1

I had to manually edit the .gitconfig file in my user directory within Windows. The editor required single quotes around it, like so:

[core]
        editor = 'C:/Program Files/Sublime Text 3/sublime_text.exe'
liamvictor
  • 3,251
  • 1
  • 22
  • 25