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:
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.
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
Create file called
npp.sh with the following content:
Double check that the path to
notepad++.exe is correct.
When you save the file, use Unix type line endings
Script is ready. Next I want to be able to just type
npp.sh <file> to make quick changes. For that to happen I will put the script into my PATH:
- Create folder
That last step you can do by opening Control Panel and searching for Environment:
Click Edit environment variables for your account and add
C:\Tools into your PATH.
Technically we are not setting editor for just commit messages but a default editor.
If you look into your
.gitconfig you can see the editor configured as follows:
Open new instance of Git Bash and test it:
Once you execute
git commit Notepad++ should start:
Write your commit message, save it and close Notepad++.
If you run into problems, check the following:
C:\Toolsin your path (
npp.shpoint to notepad.exe
You could use Notepad but writing commit messages will most likely look like this:
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.