git Editor Configurations
- There are two ways to set git editor:
- the shell’s
- The shell environment variable takes preference over the
I want to share how I debugged a git editor configuration issue where
an editor other than the one set in
git config core.editor. I will
walk through the situation and how I solved it.
By reading this, one will learn there is more than one way to configure the default editor for git and there is a configuration order. Next time you encounter an issue, here is another possible area to investigate.
This article will take about two minutes to read.
Are you having problems with the Atom editor modifying your git commit
message? Not able to
git commit --amend because the editor just
opens up and the commit message template is not there?
I found this when pairing with a coworker and they use Atom as their default editor. Everyone on the team uses a different editor, it’s either great or hell. I embrace it as there’s always something to learn and it keeps me humble. This is a situation where I learned something unexpected because of a different editor.
This issue with the git commit message happened when I wanted to amend a previous git commit message on a coworker’s computer.
git commit --amend opened up
atom, her configured git
git config core.editor) but it would show nothing.
Searching around, I discovered the issue was the editor value,
--wait is the correct parameter to use instead of just
git config core.editor='atom --wait' should have changed
the situation, the problem still persisted when running
Set it to something else!
I resorted to changing the git editor to
vim, something different. A
change of that level must work, right?
Well, when setting
git config core.editor='vim', atom still opened
git commit --amend.
(and the editor didn’t have the commit message!)
atom still launching, even when configuring the git editor
vim?! The git editor value must be coming from somewhere
else! (Either that, or someone aliased
atom, which now that
I think about it, would make great prank.)
I had a hunch that this issue was beyond just the
git config, as
changing the editor to
vim did not change anything and
Beyond git config
I looked at the environment variables set in the bash profile and noticed:
Eureka! This would explain why changing the git config editor,
When changing the GIT_EDITOR value to:
vim finally shows up with the git commit message to edit.
There are two ways to configure the git editor through:
git configthat controls all parts of git.
- The environment variable:
GIT_EDITORthat is part of the shell variables.
As someone that works with git, I never expected a shell environment
to override the
git config setting. Now I learned the order git
evaluates for its editor, even above the program’s own internal value.
GIT_EDITOR='atom --wait' also fixed the original