- Hi, I'm Cameron Mackenzie.
I'm the Editor In Chief of TheServerSide.com
and I wanted to talk to you about using Notepad
as the default editor in git.
As you well know if you have a GitHub repository,
I've got one called five commands here
and I'm gonna open up my git bash.
Can we create a new file?
I'm gonna add it to the staging area.
And the thought I had earlier was as you know,
if you do a git commit right now,
well,
all of a sudden you end up in a world of hurt here
where the vi or the Vim editor comes up and ask for changes.
I'm just going to kill that window.
What I want to do is I want to use Notepad ++ as my editor.
So how do I do that?
Well, it's as simple as issuing just a git config command
and the git config command, well,
it looks something like that.
I'm going to paste it in and read it out to you.
It's git config global.
Now you can do it system or local if you want.
Change the core setting for the editor
and specifically turn it into,
well, point to Notepad ++.
Now by the way, that might be x86
if you're on a 64-bit machine right here,
program files x86.
Make sure this is pointing to your notepad installation.
And there's a couple of switches
that I've often seen suggested for this.
So a multi-instance, not no tab bar,
no session and no plugin.
I'm going to quickly enter that
and what this means is that
a new session will come up of notepad
when you try and do a commit
and it won't load any plugins
and it won't load your previous session
when it brings up notepad.
And so you saw I couldn't do the commit earlier.
I'm going to do a git commit.
I'm not going to type anything in
and watch what happens now.
All of a sudden, notepad comes up
and you also see I've already got Notepad ++ opened up
and if you're familiar with Notepad ++,
you would know that, well typically,
new tabs are just committed each time notepad pops up.
This time it has created a brand new instance.
Now right here it wants me to type in a message.
Just type in something silly like that
and then close the editor.
It says, "Do you want to save this to commit edit message?"
And I say, "Yes."
And it commits it
and all of a sudden my commit is now done inside.
All good and there it is.
My Notepad ++ editor is working when I do a git rough log
and say after just click Save when you close the window
the commit goes in
but now all of a sudden you're using Notepad ++
or whatever text editor you want instead of vi or Emacs
or whatever your default may have already been.
And just so you know, here's the git config file.
That's the configuration file at the global level
and you'll notice that this is the edition that goes in.
Core editor equals and then pointing to the EXE file
of the editor of your choice
and that's pointing to Notepad ++.
Again, make sure it's program files
or program files X86 if you're on a 64 bit machine
and again these switches,
you might want to put those in as well.
If there's a problem,
sometimes I've seen people put double quotes
around all of that entry in its entirety there
so that everything is understood.
And I've also seen double slashes going in
where I have single slashes here.
So those are a couple of options
just in case you end up with some trouble
but as you saw that all worked Notepad ++ came up
and hey, now I can edit my commit messages
using a nice text editor that I feel comfortable with.