0

I'm using Git on Windows 7 and Sublime Text 2 as my editor.

In .gitconfig, there is this line: editor = subl -n -w

That is an incorrect entry, because I had tried to set Sublime Text as the editor for Git by using the command git config --global core.editor "subl -n -w" as described here.

but, in haste, I had not read the full instructions and didn't notice that I needed to have installed subl first. Also, this only works on a Mac!

On top of that I had mistyped the command as subi -n -w

So now, when I do:

git config --global --edit

I get the error:

error: There was a problem with the editor 'subi -n -w'

I assume that's because I had previously mistakenly mistyped the command (see above)

So then I tried setting the editor with:

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

as recommended here, which inserts the following line in .gitconfig:

editor = 'c:/program files/sublime text 2/sublime_text.exe' -w

I have also tried manually editing that line to:

editor = C:/Program Files/Sublime Text 2/sublime_text.exe -w

but I still get the error when doing git commit or git config --global --edit

I have tried to use unset:

git config --global --unset-all core.editor

and then re-input Sublime Text as the editor (manually and using command line). I still get the error message and Sublime Text is not launched (for git commit). How do I get rid of the error message and successfully launch Sublime Text as the editor?

Community
  • 1
  • 1
Hunsecker
  • 151
  • 1
  • 6

2 Answers2

0

Is it possible that, during your numerous attempts to get the original mistake corrected, you inserted an offending (non-printable) character in the .gitconfig file?

One thing I might try is:

  1. Create a new git repository in a dummy directory
  2. View/Copy the .gitconfig from that project into your current project
  3. Edit the .gitconfig with the correct path/filename to execute Sublime

I do not profess to know this is the solution. It is just a creative approach to solving your problem.

Please report your results for others who may stumble across this in the future (it may very well even be ME! < smile >).

Thom Parkin
  • 346
  • 1
  • 9
0

I solved this by opening up the config in the project directory and spotting that the following line was in there:

editor = subi -n -w

(i.e. the erroneous line)

I simply removed it and problem solved, i.e. Sublime Text now responds to the system wide .gitconfig line:

editor = 'C:/Program Files/Sublime Text 2/sublime_text.exe' -w`

I hadn't quite understood local project configuration, so thanks to @Thom Parkin for leading me on a path to the solution

Hunsecker
  • 151
  • 1
  • 6