This one is pretty simple, but the syntax is maybe not so helpful. Here's the story:
I am getting ready to lead a walkthrough for my company on how to use GIT (we make instruments, so software management is not at the forefront of most people's minds). In thinking about how to deploy this walkthrough I realized that my affinity for VIM is probably not shared throughout the company. The solution can be found in the command:
git config --global core.editor <editor_path>
The trick comes in setting the editor path. When I set the editor path to the location on the file system using:
"c:/Program Files (x86)/Notepad++/Notepad++.exe"
I received the following errors:
$ git commit
c:/Program Files (x86)/Notepad++/notepad++.exe: -c: line 0: syntax error near unexpected token `('
c:/Program Files (x86)/Notepad++/notepad++.exe: -c: line 0: `c:/Program Files (x86)/Notepad++/notepad++.exe \$@\'
error: There was a problem with the editor 'c:/Program Files (x86)/Notepad++/notepad++.exe'.
Please supply the message using either -m or -F option.
I think the trouble is due to how git is parsing the path of the editor, namely that it is seeing the spaces as argument separators. The problem can be fixed by placing an extra set of quotes around the editor path like so:
'"c:/Program Files (x86)/Notepad++/Notepad++.exe"'
Git will now see the editor path as one parameter.
One extra note, Notepad++ has lots of extra features that are nice when working on a project, but these can be a nuisance when editing your commit messages. The biggest offender is that by default Notepad++ will restore your session and open the commit message in a new tab. To prevent this default behavior some extra command line parameters are required. My final statement to configure the git editor is:
$ git config --global core.editor '"c:/Program Files (x86)/Notepad++/notepad++.exe" -multiInst -notabbar -nosession -noPlugin "$*"'
Note: the "$*" argument tells bash where to place the arguments from GIT. More on special bash arguments
here.
Happy GITing!