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.
So I figured out I need to have an environment variable called EDITOR. No problem. I set it to point to Notepad. That worked, almost. The default commit message opens in Notepad. But Notepad doesn't support bare line feeds. I went out and got Notepad++, but I can't figure out how to get Notepad++ set up as the %EDITOR%
in such a way that it works with Git as expected.
I'm not married to Notepad++. At this point I don't mind what editor I use. I just want to be able to type commit messages in an editor rather than the command line (with -m
).
Those of you using Git on Windows: What tool do you use to edit your commit messages, and what did you have to do to make it work?
This works for Powershell and cmder-1.2 (when used with powershell). In ~/.gitconfig
How can I make Sublime Text the default editor for Git?
This is working for me using Cygwin and Textpad 6 (EDIT: also working with Textpad 5 as long as you make the obvious change to the script), and presumably the model could be used for other editors as well:
~/.gitconfig:
~/script/textpad.sh
This one-liner works as well:
~/script/textpad.sh (option 2):
Edit: After updating to vim 7.3, I've come to the conclusion that the cleanest and easiest way to do this is:
Add Vim's main folder to your path (Right click on My Computer -> Properties -> Advanced -> Environment Variables)
Run this:
git config --global core.editor "gvim --nofork '%*'"
If you do it this way, then I am fairly sure it will work with cygwin as well.
Original answer:
Even with a couple of vim-related answers, I was having trouble getting this to work with gvim under Windows (while not using a batch file or %EDITOR% or cygwin).
What I eventually arrived at is nice and clean, and draws from a few of the solutions here:
One gotcha that took me a while is these are not the Windows-style backslashes, they are normal forward slashes.
Building on Darren's answer, to use Notepad++ you can simply do this (all on one line):
git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
Obviously the
C:/Program Files/Notepad++/notepad++.exe
part should be the path to the Notepad++ executable on your system. For example, it might beC:/Program Files (x86)/Notepad++/notepad++.exe
.Works like a charm for me.
Based on VonC suggestion above, this worked for me (was driving me crazy):
Omitting
-wait
can cause problems especially if you are working with gerrit and change ids that have to be manually copied to the bottom of your commit messageNotepad++ works just fine, although I choose to stick with Notepad, -m, or even sometimes the built-in "edit."
The problem you are encountering using Notepad++ is related to how git is launching the editor executable. My solution to this is to set EDITOR to a batch file, rather than the actual editor executable, that does the following:
/WAIT tells the command line session to halt until the application exits, thus you will be able to edit to your heart's content while git happily waits for you. %* passes all arguments to the batch file through to Notepad++.