BACKGROUND IMAGE: deepagopi2011/stock.adobe.com
For the most part, developers who are new to the Git tool don’t have too much of a problem mastering the five basic git commands every beginner should learn. But one speed-bump that does tend to trip up new users is the fact that the Git editor defaults to Vim. For those with a Windows background, figuring out how to add a comment, save the entry and then exit the Vim Git editor can be frustrating, if not a little scary.
Changing the Git editor to Notepad++
Fortunately, it’s not that difficult to change the default Git editor to a text editor of your choosing, be it Notepad, EditPad or my personal favorite, Notepad++. All you have to do is issue a git config command and specify the core editor of your choice. The config command to change the default Git editor to Notepad++ is as follows:
gitbeginner@devops MINGW32 /c/ change git/ default editor $ git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
It should be noted that I issued this command on a Windows 32-bit machine. Obviously, on an x64 machine, Notepad++ would be found under the Program Files (x86) directory. The bottom line is that when you run this command, make sure you provide the correct location of your text editor of choice.
This change to the default Git text editor was specified to take place at the global Git scope, so the change can be inspected by opening the .gitconfig file found under the user’s home directory. Upon inspection, you will note that a new core heading has been added to the Git configuration file and the editor property has been set to Notepad++:
[core] editor = 'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin
Using Notepad++ as the Git editor
As far as the switches after the listing of the executable, those are all Notepad++ specific and have nothing to do with Git. These popular switches ensure that a new Notepad window is displayed, rather than just adding a new tab to an existing Notepad++ instance that might already be running. The switches also ensure that no plugins are loaded into Notepad++, which might make loading Notepad++ faster while avoiding any problems with misconfigured plugins. The -nosession switch tells Notepad++ not to bring up any files from previous sessions, ensuring that the current commit is the only thing the text editor displays.
The next time you issue a git commit without specifying a commit message, Notepad++ will pop up. Just add a message, click save and close the window. The message you typed in will then become part of the history of the git branch upon which you are working.
Become a Git power user
Want to become a Git power user? Take a look at the following Git articles and tutorials
- How to do a Git clean up of branches and commits
- Learn to rebase onto master and rebase from the master branch
- Squash all Git commits on a branch down to one
- Shelve your changes with Git stash pop and apply
- Easily explain the Git vs GitHub difference
- Add a shallow git clone of depth 1 do your Jenkins jobs
- Set up a local Git server with a bare Git repo