git config username and email set to blank automatically

Viewed 1421

I'm having some problems with my global git config. Both username and email is set to blank automatically. I can't figure out if there is a pattern to this behaviour, but more often than not git tells me to set username and email when I'm trying to make a commit. Updating using git config --global or directly editing my .gitconfig file both works, but after some time they disappear again.

File content before reset:

[user]
    name = <name>
    email = <email>
[core]
    editor = atom --wait
    excludesfile = /Users/christian/.gitignore_global
[pull]
    rebase = false

File content after reset:

[user]
    name = 
    email = 
[core]
    editor = atom --wait
    excludesfile = /Users/christian/.gitignore_global
[pull]
    rebase = false
2 Answers

As confirmed by Isaac Betesh this is an Atom problem, where some interactions with tabs from different repositories wipe out the global user/email config. The issue is at: https://github.com/atom/github/issues/2558

I've temporarily worked around the problem by removing the write permission from ~/.gitconfig

In addition of checking what could delete your ~/.gitconfig global Git configuration, check also if git config user.useConfigOnly is set to true.

Since Git 2.8, that would also force you to set your user.name/email for each repository.

You would also see the effect of that configuration in the error message:

no name was given and auto-detection is disabled
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If not, then it is back to check if, when you have the issue, your global .gitconfig is deleted or somehow changed/reset.

Related