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
Use the selected commit message without launching an editor. For example, git commit --amend --no-edit amends a commit without changing its commit message. Replace the tip of the current branch by creating a new commit.
The command to do this is git config --global core. editor "nano" . You can change the highlighted section with your editor of choice!
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With