Using Notepad++ to Write Git Commit Messages

When configuring new machine, I never remember all the small tricks and I end up googling for solutions. The information presented here can be found from the How do I use Notepad++ with msysgit post. You just have to put the different steps together. I decided to document it here so that I don’t have to wade through multiple stackoverflow posts next time.


After issuing command git commit lot of people find themselves in the following situation:

VIM as editor

Technically you have an editor open and you could just write the commit message and continue. That is if you know your way around vi. As with all things Git there are many ways to do things and end up with the same result. The solution presented here is not the only way to achieve the same result.

Shell script to start Notepad++

Note that I’m using Git Bash so if you are using Command Prompt or PowerShell you need to tweak the script to suit your environment (e.g. write valid .bat file).

Create file called with the following content:

"c:\Program Files (x86)\Notepad++\notepad++.exe" -multiInst -notabbar -nosession -noPlugin "$*"

Double check that the path to notepad++.exe is correct.

When you save the file, use Unix type line endings

UNIX Line Endings


Script is ready. Next I want to be able to just type <file> to make quick changes. For that to happen I will put the script into my PATH:

  1. Create folder C:\Tools
  2. Put into C:\Tools
  3. Add C:\Tools into your PATH

That last step you can do by opening Control Panel and searching for Environment:

Control Panel

Click Edit environment variables for your account and add C:\Tools into your PATH.

Configure editor in .gitconfig

Technically we are not setting editor for just commit messages but a default editor.

git config --global core.editor

If you look into your .gitconfig you can see the editor configured as follows:

editor =


Open new instance of Git Bash and test it:

$ mkdir npp-test
$ cd npp-test/
$ git init
Initialized empty Git repository in C:/npp-test/.git/
$ echo "testing" > file.txt
$ git add file.txt
$ git commit

Once you execute git commit Notepad++ should start:

Using Notepad++ to write commit message

Write your commit message, save it and close Notepad++.


If you run into problems, check the following:

  • Is C:\Tools in your path (env|grep Tools)
  • Does point to notepad.exe

Why not Notepad

You could use Notepad but writing commit messages will most likely look like this:

Using Notepad to write commit message

As you can see Notepad does not handle the UNIX style line endings correctly. I don’t know if this is related to Git Bash. Maybe you have better luck if you are using Command Prompt/PowerShell with Git.