I just launched a new course on ES6! Use the code WESBOS for $10 off.

Strengthen your core JavaScript skills and master all that ES6 has to offer. Start Now →

Associate Sublime Text with Git

By default, git uses Vim as the editor for commit/rebase messages. This can be somewhat limiting if you aren’t comfortable with using Vim, especially if you need to move around lines of code.

Luckily it’s easy to switch over to using Sublime Text as the editor for your messages. When git needs you to input and save a message. It will simply open up Sublime Text and prompt you with the file that needs editing. Once you save and close the file, git will continue on with what it needs to do.

Install subl

First thing we need to do is to make Sublime accessible via the command line. Chances are you might already have this installed, but if you haven’t, you can follow the instructions here. If you are still on Sublime Text 2 – follow these instead.

Set git to use

Next, open up your Terminal or command line and paste the following:

git config --global core.editor "subl -n -w"

That’s it! Next time Git requires you to edit a file or commit message, Sublime Text will pop open!

This entry was posted in Sublime Text. Bookmark the permalink.

2 Responses to Associate Sublime Text with Git

  1. jitendra vyas says:

    Is this possible on windows?

    • wesbos says:

      Yes! You’ll need to do this to enable the `subl` command:

      doskey subl=”C:\Program Files\Sublime Text 2\sublime_text.exe” $*

      and then follow this tutorial as normal

Leave a Reply

Your email address will not be published. Required fields are marked *