Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up sublimetext 3 as git commit text editor

I'm having trouble setting up sublime as my git commit message editor.

Using:

git config --global core.editor "subl" 

Error: error: cannot run subl: No such file or directory error: unable to start editor 'subl' Please supply the message using either -m or -F option.

subl work perfectly otherwise.

like image 224
Alan Quigley Avatar asked Mar 25 '14 10:03

Alan Quigley


People also ask

How do I change the default text editor in git?

The command to do this is git config --global core. editor "nano" . You can change the highlighted section with your editor of choice!

What is the default git text editor?

On Windows, if you use Git Bash the default editor will be Vim. Vim is another text editor, like nano or notepad.

Does Sublime Text support git?

The Git features available in Sublime Text were derived from work that went into our other product, Sublime Merge. Sublime Merge is a full-featured, blazing-fast Git client built upon the technologies from Sublime Text.


1 Answers

For what it's worth, here's how I solved it:

1) Run in Terminal:

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

This adds a subl alias to /usr/local/bin/ pointing to Sublime Text 3 app’s binary file. Now running subl in Terminal will launch Sublime Text 3 app.

2) Run in Terminal:

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

This adds editor = subl -n -w to the [core] section of the ~/.gitconfig file. Now running git commit in Terminal will launch Sublime Text 3 app (subl) in a new window (-n), and the command line will wait (-w) until the commit message is saved and closed.

Image of final workflow added in response to clarifying question in comments below:

enter image description here

Official Sublime Text 3 doc: http://www.sublimetext.com/docs/3/osx_command_line.html

like image 182
2540625 Avatar answered Sep 17 '22 17:09

2540625