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?
I prefer to use emacs. Getting it set up can be a little tricky.
c:\emacs
.c:\emacs\bin\addpm.exe
. You need to right-click and "Run as Administrator" if you are using Windows Vista or above. This will put the executables in your path.(server-start)
somewhere in your.emacs
file. See the Emacs Windows FAQ for advice on where to put your.emacs
file.git config --global core.editor emacsclientw
Git will now open files within an existing emacs process. You will have to run that existing process manually from
c:\emacs\bin\runemacs.exe
.ATOM and Windows 10
Typed this in the git bash:
git config --global core.editor C:/Users/YOURNAMEUSER/AppData/Local/atom/app-1.7.4/atom.exe"
Note: I changed all
\
for/
. I created a .bashrc at my home directory and used/
to set my home directory and it worked, so i assumed/
will be the way to go.atom-editor git git-bash windows-10
I use Cygwin on Windows, so I use:
The
-nw
is forno-windows
, i.e. tell Emacs not to try and use X11.The Emacs keybindings don't work for me from a Windows shell, so I would only use this from a Cygwin shell... (rxvt recommended.)
When using a remotely mounted homedrive (samba share, nfs, ...) your
~/.git
folder is shared acros all systems which can lead to several problems. Thus I prefer a script to determine the right editor for the right system:One might consider a plain shell script but I used perl as is perl is shipped with msysgit und your unixoid systems will provide one as well. Putting the script in
/home/username/bin
, which should be added toPATH
in.bashrc
or.profile
. Once added withgit config --global core.editor giteditor.pl
you have the right editor, wherever you are.This is the 1 symptom of greater issues. Notably that you have something setting TERM=dumb. Other things that don't work properly are the
less
command which says you don't have a fully functional terminal. It seems like this is most commonly caused by having TERM set to something in your global windows environment variables. For me, the issue came up when I installed Strawberry Perl some info about this is on the msysgit bug for this problem as well as several solutions.The first solution is to fix it in your ~/.bashrc by adding:
You can do this from the Git BASH prompt like so:
The other solution which ultimately is what I did because I don't care about Strawberry Perl's reasons for adding TERM=dumb to my environment settings is to go and remove the TERM=dumb as directed in this comment on the msysgit bug report.
Similarly if you use Strawberry Perl and care about the CPAN client or something like that, you can leave the
TERM=dumb
alone and useunset TERM
in your ~/.bashrc file which will have a similar effect to setting an explicit term as above.Of course all the other solutions are correct that you can use
git config --global core.editor $MYFAVORITEEDITOR
to make sure that git uses your favorite editor when it needs to launch one for you.Anyway, I've just been playing around with this and found the following to work nicely for me:
I don't think CMD likes single-quotes so you must use double quotes "to specify the space embedded string argument".
Cygwin (which I believe is the underlying platform for Git's Bash) on the other hand likes both
'
and"
; you can specify a CMD-like paths, using/
instead of\
, so long as the string is quoted i.e. in this instance, using single-quotes.The
-m
overrides/indicates the use of multiple editors and there is no need for a%*
tacked on the end.