7

I have a problem in which whenever I run git commit this shows up:

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

subl is an alias for sublime. I am running git Bash on Win10.
If I just run 'subl', it opens the editor without a problem, but with git commit it doesn't. Here is my git config file:

[core] editor = subl -w -n 

3 Answers 3

8

Execute git config --global core.editor "\"C:\Program Files\Sublime Text 3\sublime_text.exe\" %*" to configure Sublime as your editor in Windows.

EDIT: The above assumes you have Sublime 3 installed. If you have Sublime 2 installed, change the full path to the correct valid path to sublime_text.exe.

Sign up to request clarification or add additional context in comments.

4 Comments

Doesn't git-bash use UNIX-style file paths? Would it recognize Windows file paths?
Works for me on Windows 7 w/ Git Bash.
it seems that when invoking the path, git doesn't recognize the spaces. C:/Program Files/Sublime Text 3/sublime_text.exe -w -n: C:/Program: No such file or directory . Adding \ before spaces doesn't work either (fatal: bad config line 4 in file C:/Users/Lucas/.gitconfig ) – Lucas Rebelo 8 mins ago
@LucasRebelo Try running git config --global core.editor "\"c:\Program Files\Sublime Text 3\sublime_text.exe\" %*" from your git bash.
2

Shell aliases are a feature of the shell and not of the operating system. They can therefore only be executed directly by the shell, and not through any external tools like git.

For the same reason you can not use aliases with find -exec, xargs or sudo.

If you want a shorter way to run something that also works with external tools, create a shell script with that name instead.

Comments

1

Try setting the whole path to subl like /usr/local/bin/subl or whatever it is on your system. You can find out by executing which subl in your terminal.

It's possible that whatever env your git is running in, it's not aware of your aliases.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.