The problem is that the Sublime Text command-line tool by default tells the Sublime Text GUI to open a file, and then exits right away, even while the GUI still has the file open. There's an option, though, that'll tell the command-line tool to wait for the file to be closed in the GUI. That option is --wait
(or -w
for short). So if I try this:
: $; git config core.editor subl
: $; git commit
... I get the following -- with the first line showing briefly then getting erased and replaced by the second:
hint: Waiting for your editor to close the file...
Aborting commit due to empty commit message.
You may or may not see the first line, as this all happens at about the same time as the Sublime Text GUI is becoming visible, and opening up the COMMIT_MESSAGE file. And when you return to the Terminal, you'll see only the second line.
But if I add the option to wait, it works. So I change the editor like so:
: $; git config core.editor 'subl -w'
And then if I do a git commit
, and switch from Sublime Text to the Terminal without closing the COMMIT_MESSAGE file, I see:
: $; git commit
hint: Waiting for your editor to close the file...
And then if I go back and close the file (after writing in some text and saving it), I come back to see:
: $; git commit
[master 79d5a7b] Commit message I typed in Sublime Text GUI.
1 file changed, 1 insertion(+), 1 deletion(-)