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?

+3


source to share


4 answers


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.

+2


source


Justin's answer worked for me, but I had to use double quotes rather than single quotes.



git config --global core.editor "C:/Program Files/Sublime Text 2/sublime_text.exe -w -n"

      

+4


source


I changed / to \ and it worked for me on Windows 10. I am using sublime text 3.

git config --global core.editor "C:\Program Files\Sublime Text 3\sublime_text.exe -w -n"

      

+1


source


You might want to try the following:

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

      

-n opens a new window

-w expects open files to be saved before closing

0


source







All Articles