Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I finish editing a commit message with Sublime Text?

I configured Sublime Text as my Git commit editor. When I do git commit Sublime opens and I write the commit message and then I save the file and close it, but in the git terminal it is still stuck in the git commit, and didn't return the console to me!.

How do I return to the console after editing with Sublime?

like image 631
osama7901 Avatar asked Nov 02 '16 09:11

osama7901


2 Answers

I think you need -w. Try setting Sublime as the editor for git with

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

This will wait with returning until you actually close the file, which will work better for git.

You may also want to use -n, which will start a new Sublime window for your commit message so that when you close it, the files you were working on are unaffected (you don't have to close your main editor window):

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

Or on Windows, something like

git config --global core.editor "'c:/program files/sublime text 3/sublime_text.exe' -w -n"

I think it's not possible to do it upon closing the tab in a multi-tab window though, at least not trivially.

like image 95
Gabor Lengyel Avatar answered Nov 08 '22 20:11

Gabor Lengyel


I had the same problem after making sublime my editor with -n (new window) -w (wait) options. What worked for me was making sure they are both running with the same privileges i.e. if shell is running elevated then sublime has to be elevated and vice versa if shell isn't elevated then sublime shouldn't be elevated.

like image 21
Joseph Evensen Avatar answered Nov 08 '22 21:11

Joseph Evensen