Sublime Forum

Need new sublime instance(new process) for git commit editor workflow

#1

First of all sublime is great and I seriously cannot ask you more. But recently I faced a problem.

To use sublime as my git commit editor I see people/blogs suggesting subl -w -n. Even though this solution works fine if u don’t have sublime already opened. I see it broken when u are already busy working in an existing sublime instance.

My workflow:
I always open sublime and edit my code changes and then move to cmd.exe and do git add; git commit.This as configured open a new sublime window(not a new sublime_text.exe process) and allows me to edit the commit message. But now for the git commit command to exit I have to close my sublime_text.exe process in which I am editing my project!

Looks like there is no flag to subl.exe for sublime_text.exe to spawn a new instance. Is there a workaround or fix for it?

2 Likes

#2

I always have ST running and use it as my editor for git without problems.

C:\Users\Fichte>echo %editor%
subl -nw

C:\Users\Fichte>where subl
C:\Program Files\Sublime Text 3\subl.exe
0 Likes

#3

@FichteFoll Could u please try below workflow

  1. Open sublime with subl . This opens the current directory in sublime
  2. subl -n -w a.txt This will open a new sublime window and wait
  3. edit a.txt and save and close the window opened in step 2.
  4. Now you will see subl -n -w a.txt still waiting!! This command exits only when sublime of step 1 is closed(which is terminating the sublime_text.exe process).

Step 2 is how git commit invokes sublime.

Sorry for not being clear in my question.

0 Likes

#4

Your question was clear, but as @FichteFoll mentions, this works just fine. If this doesn’t work for you, there is some other subtle issue going on, although I’m not sure what it would be. Possibly a problem with a plugin somehow blocking things? Does it maintain incorrect behaviour if you temporarily disable all of your plugins?

2 Likes

#5

@OdatNurd Thanks for the reply, I tried disabling the plugins. Looks like https://packagecontrol.io/packages/EncodingHelper is causing the issue(The plugin now removed from package control) so just an “upgrade/overwrite all packages” fixed the issue. I am still not sure if that is the plugin which caused the behaviour.

0 Likes

#6

I am having this same issue.
It is new for me. I migrated to a new computer, I have no plugins installed.
And I do have my gitconfig setup to use sublime text, using the -n -w flags.

As usual, a new window/instance of sublime text is opened.
I type my commit message. Save the file.
Close the file, and window.

But git is still waiting for me to close the file !
I (now) have to Exit Sublime Text altogether before git will complete the commit !!

This is terrible. I’m not sure what could have changed to cause this odd, behaviour. Like I said, I’ve not yet migrated my settings or “plugins” yet ;-( so that could not be causing the issue in my case.

Any ideas?

(PS I also need an easy way to import all my settings and plugins)

0 Likes

#7

Hi @sheryl first make sure your .gitconfig contains below.

[core]
	editor = subl -n -w 

The reason why you have to exit entire sublime is because I am sure you are opening initial sublime as admin(may be via a admin cmd) and you are invoking git commit from normal non admin(elevated) cmd or vise versa. sublime_text.exe and subl.exe does not work as expected when one is an admin process and other is a non admin process.

This is also very annoying when you try to open a file in sublime from explorer(via right click) when an admin sublime is already running. The file from explorer will never be opened in the admin sublime :frowning:

The workaround is, either run both of them(sublime and git) from an admin cmd or run both of them from a non admin cmd.

Also, I don’t think this has nothing to do with the plugins. Ignore my previous response :slight_smile:

Hope this helps.

1 Like

#8

There is also this undocumented --multiinstance flag which essentially spawns a new sublime_text process which will inherit your current cmd privilege level, so once you close this new instance of the editor, git will be happy and saves the commit message :slight_smile:

[core]
	editor = sublime_text.exe --multiinstance
1 Like

#9

related:

1 Like