Sourcetree - Aborting commit due to empty commit message, all editors not working

Viewed 186

I am facing a perplexing problem where on Sourcetree I am getting an error while doing Interactive Rebase AND doing Ammend commit. The error I'm getting is as shown, error.

I've looked on the forums here and I've tried several solutions to no avail. The one that comes up the most is

git config --global core.editor "[your editor] -w"

I've tried VSCode and sublime with no luck. To the best of my knowledge, after pressing okay the external editor should pop up; however, it never does and goes to the error in the image attached. I've also confirmed that just typing in "code" into my terminal brings up VSCode so it looks like that path works.

Looking for any potential suggestions, that would be greatly appreciated!

2 Answers

The explicit command in your screenshot contains :

git ... -c core.editor '<some path>' ... rebase -i ...

This means that, for the duration of that command, the value for core.editor will be replaced with <some path>. Since it looks like it's also the sequence.editor, I guess it is a non interactive script geared towards editing the sequence of actions for git rebase -i ; for some reason, it doesn't do a correct job at providing a commit message.

(btw : SO favors text over screenshots, it makes for easier copy/pasting ...)


To fix your issue :

Read the docs for Sourcetree to understand what this script does, or run the rebase -i yourself from the command line.

The problem here is that your editor configuration is improperly specified.

The editor you specify in core.editor, sequence.editor, or in other ways of specifying the editor (like the EDITOR and VISUAL environment variables) is always passed to the shell. The shell that's used is always a POSIX shell, because that's portable (it works the same on all systems) and it's powerful enough to allow functional and effective scripting.

As a result, you need to basically assume that your editor will be invoked from the shell (e.g., in Git Bash) as EDITOR FILE, where EDITOR is the editor value. In the example you've shown with your screenshot, you've got something like this: C:\Users\Chad\...\foo.exe. The problem is that backslashes are special to the shell and generally will end up being removed.

Whatever editor you're specifying, as well as whatever editor SourceTree is specifying in the commands its invoking, needs to use forward slashes instead of backslashes, or it'll need additional quoting to prevent the shell from removing the backslashes. How you tell SourceTree to do this, I don't know, but that's almost certainly the problem here.

Related