On my new Ubuntu laptop, I installed git one day and was making a commit not long after. I was surprised with an editor that I never use: nano. I wanted VIM.
First, make sure you have the text editor you want is installed. In my case, I wanted VIM, so I ran:
sudo apt-get install vim. It turns out that ubuntu doesn’t come with VIM installed by default. So it installed without any trouble.
I was reading this Stack Overflow thread about doing setting the core.editor property, but it didn’t work. It turns out that the simple command,
git config core.editor "vim" doesn’t set the property for all git repositories, just the local folder. If you try to do it in a non-repo folder, it’ll scream at you:
error: could not lock config file .git/config: No such file or directory
The solution is of course to add a global option. Run the same command but with global enabled, and it’ll set all repos to use the same text editor:
git config --global core.editor "vim". Note the two dashes, that’s very important.
That’s all there is to changing the default editor for git in Ubuntu.