git 配置用户名和电子邮件设置为自动空白

git config username and email set to blank automatically

我的全局 git 配置有一些问题。用户名和电子邮件都自动设置为空白。我无法弄清楚这种行为是否存在某种模式,但 git 通常会在我尝试提交时告诉我设置用户名和电子邮件。 使用 git config --global 更新或直接编辑我的 .gitconfig 文件都有效,但一段时间后它们又消失了。

重置前的文件内容:

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

重置后的文件内容:

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

除了检查什么可以删除您的 ~/.gitconfig 全局 Git 配置外,还要检查 git config user.useConfigOnly 是否设置为 true。

Since Git 2.8,这也会迫使您为每个存储库设置用户。name/email。

您还会在错误消息中看到该配置的效果:

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

如果没有,那么当你遇到问题时,它会返回检查你的全局 .gitconfig 是否被删除或不知何故 changed/reset.

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

确认

我通过删除 ~/.gitconfig

的写权限暂时解决了这个问题