Git Tips: Make Sublime as editor for git operations in macOS

I would like to use Sublime editor for git (esp. rebase) editing operations rather than default vi editor in macOS. The following steps will help you to configure Sublime as your git editor.

Make Sublime accessible from anywhere in the terminal

In macOS, subl command that can be used to invoke Sublime (version 3) from the terminal is located at

/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl

First we have to make this accessible from anywhere in the terminal. For that, create a symbolic link to any folder that is already part of PATH variable

ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl

Set Sublime as git editor

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

Additional parameters do the following here:

  • -n tells git to open a new editor window
  • -w tells git to wait until the commit message is saved

This should get it working for you! Try out by running the command

git rebase -i HEAD~

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: