Reputation: 3
I am learning the basics of Git and have run into an issue while trying to use Sublime 2 as my default text editor for commit messages.
I am using a Mac and the Sublime text editor(Version 2.0.2, Build 2221)
As per instructions on help.github I used the following line:
git config --global core.editor "subl -n -w"
However, when I attempt a git commit
command I get the following message:
subl -n -w: subl: command not found
error: There was a problem with the editor 'subl -n -w'.
Please supply the message using either -m or -F option.
I know that subl
and subl -n -w
work as I have tried them in isolation and they launch the editor. So the issue must be when the editor is opened from the git commit
command.
I have looked at the questions and answers from 1, 2 & 3 and attempted the solutions but haven't been able to resolve my issue.
Upvotes: 0
Views: 466
Reputation: 491
I encountered the same error trying to configure Sublime Text 3 for git commit messages on Mac. Like you, the subl
terminal command launched Sublime Text 3 but produced an error when used with git commit
.
I initially tried git config --global core.editor "subl -n -w"
and got:
subl -n -w: subl: command not found
error: There was a problem with the editor 'subl -n -w'.
Please supply the message using either -m or -F option.
Then I tried the following, substituting subl
with the absolute path:
$ git config --global core.editor "'/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl' -n -w"
and received the following error:
'/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl' -n -w: /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl: No such file or directory
error: There was a problem with the editor ''/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl' -n -w'.
Please supply the message using either -m or -F option.
This was because the absolute file path contained an escaping backslash that is unnecessary. Once I removed the backslash it worked!
The correct git config
command is:
$ git config --global core.editor "'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl' -n -w"
Ta daa!
Upvotes: 1
Reputation: 1205
This answer assumes Git and Sublime Text 2 are properly installed. See this page if you haven't already updated to the latest version of Git for Mac: https://git-scm.com/download/mac
cd /usr/local/bin
and verify /usr/local/bin
exists. Create /usr/local/bin
if necessary.echo $PATH
and verify bin:/usr/local/bin
is present in the path. Add bin:/usr/local/bin
to the path if necessary.ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
and enter your password when prompted.subl
and verify Sublime Text 2 opens. Close Sublime Text 2.git config --global core.editor "subl -n -w"
. Sublime Text 2 should now be configured as your editor for Git commit messages.Upvotes: 1