How to configure Git to use NotePad++ as editor on Windows?

About

This article shows you how you can configure git to use Notepad as editor on your laptop.

Steps

Create your editor bat script

Git calls a command with one parameter the path of the file.

The command should terminate with the status 1.

Because Notepad will open a new file in its actual process, you should then closed Notepad and your open files each time.

To change this behavior, we wrote a dos script that will wrap the Notepad command invocation.

The script below will open a file in a new instance of Notepad.

@ECHO OFF

REM 
notepad++.exe -multiInst %1

Add it to your path environment variable

To be able to call this script from everywhere, you should add it to your PATH environment variable.

In my case, I store all shell scripts that I reuse in the directory D:\code\shell-gt (They are in a git repository and in-sync on all machines).

Windows Envrionment Variable Path Shell Script

Configure the new editor command

The last step is to tell git to use our script with git config.

git config --global core.editor ed.bat

Next

That's it.

The next time that Git needs a description (for instance, for a commit), if you don't provide a message at the command line, Git will open Notepad++ asking you

  • to write a message,
  • to save the file
  • and to close Notepad





Discover More
Git - Config

The git config command. The name is actually: the section and the key separated by a dot. The value will be escaped. Example: where: core.editor is the name whereas: core is the section...



Share this page:
Follow us:
Task Runner