osama7901
osama7901

Reputation: 1671

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?

Upvotes: 6

Views: 2563

Answers (3)

M. Brickler
M. Brickler

Reputation: 1

from Sublime Text 3 Command Palette (Ctrl-shift-p), I go to the Commit (git: Commit), type in the text and do a Ctrl-w to save and close it.

Upvotes: 0

Joseph Evensen
Joseph Evensen

Reputation: 171

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.

Upvotes: 2

Gabor Lengyel
Gabor Lengyel

Reputation: 15570

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.

Upvotes: 12

Related Questions