Git opening Sublime on Windows
I followed the instructions below and they worked "great". In fact, they did exactly what they said on the box. The problem is that when I run a command like git commit, I want it to use sublime as the post editor.
Window
Find the directory where Sublime is located. For many people, this is C: / Program \ Files / Sublime \ Text \ 2 / sublime_text.exe. To test this, run ls C: / Program \ Files / Sublime \ Text \ 2 inside git Bash. You should review the list of sublime_text.exe. If you get the error No such file or directory, Sublime is somewhere else for you to find. For example, it could be in the C: / Program \ Files \ (X86) `folder.
Run the following command in git Bash: echo 'alias subl = "C: / Program \ Files / Sublime \ Text \ 2 / sublime_text.exe"' → ~ / .bashrc If subl was in a different directory for you in step 1, use this catalog.
Close and reopen git Bash. Typing text under the git Bash heading should now open Sublime.
I know that I have to run the command
git config --global core.editor "subl"
But then below error message is executed when I try to use git commit
error: cannot occur subl: no such file or directory error: not possible start editor 'subl' Please post a message using the -m or -F option.
Can anyone shed some light on what I should be doing?
source to share
In the end it worked for me. I ignored the alias I already created.
git config --global core.editor 'C:/Program Files/Sublime Text 2/sublime_text.exe -w -n'
The -w flag means that git bash should wait for a result from Sublime to return. Without that, it won't work. It will open Sublime, but then immediately display an error message.
The -n flag means it will open a new Sublime window. This is very useful as you need to close Sublime to add the message back to git bash terminal, and if you have other documents open in that Sublime window, you will need to open another Sublime.
source to share