I'm trying out Git on Windows. I got to the point of trying "git commit" and I got this error:
Terminal is dumb but no VISUAL nor
EDITOR defined. Please supply the
message using either -m or -F option.
Update September 2015 (6 years later)
The last release of git-for-Windows (2.5.3) now includes:
git config core.editor notepad, users can now use
notepad.exeas their default editor.
git config format.commitMessageColumns 72will be picked up by the notepad wrapper and line-wrap the commit message after the user edits it.
I just tested it with git version 1.6.2.msysgit.0.186.gf7512 and Notepad++5.3.1
I prefer to not have to set an EDITOR variable, so I tried:
git config --global core.editor "\"c:\Program Files\Notepad++\notepad++.exe\"" # or git config --global core.editor "\"c:\Program Files\Notepad++\notepad++.exe\" %*"
That always gives:
C:\prog\git>git config --global --edit "c:\Program Files\Notepad++\notepad++.exe" %*: c:\Program Files\Notepad++\notepad++.exe: command not found error: There was a problem with the editor '"c:\Program Files\Notepad++\notepad++.exe" %*'.
If I define a npp.bat including:
"c:\Program Files\Notepad++\notepad++.exe" %*
and I type:
C:\prog\git>git config --global core.editor C:\prog\git\npp.bat
It just works from the DOS session, but not from the git shell.
(not that with the core.editor configuration mechanism, a script with "
start /WAIT..." in it would not work, but only open a new DOS window)
Bennett's answer mentions the possibility to avoid adding a script, but to reference directly the program itself between simple quotes:
git config --global core.editor \ "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
Or if you are in a 64 bit system:
git config --global core.editor \ "'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
But I prefer using a script (see below): that way I can play with different paths or different options without having to register again a
The actual solution (with a script) was to realize that:
what you refer to in the config file is actually a shell (
/bin/sh) script, not a DOS script.
So what does work is:
C:\prog\git>git config --global core.editor C:/prog/git/npp.bat
#!/bin/sh "c:/Program Files/Notepad++/notepad++.exe" -multiInst "$*"
#!/bin/sh "c:/Program Files/Notepad++/notepad++.exe" -multiInst -notabbar -nosession -noPlugin "$*"
With that setting, I can do '
git config --global --edit' from DOS or Git Shell, or I can do '
git rebase -i ...' from DOS or Git Shell.
Bot commands will trigger a new instance of notepad++ (hence the
-multiInst' option), and wait for that instance to be closed before going on.
Note that I use only '/', not
\'. And I installed msysgit using option 2. (Add the
git\bin directory to the
PATH environment variable, but without overriding some built-in windows tools)
The fact that the notepad++ wrapper is called .bat is not important.
It would be better to name it 'npp.sh' and to put it in the
[git]\cmd directory though (or in any directory referenced by your PATH environment variable).