为什么 Git 甚至在配置之后都不允许我提交?

这个问题看起来像是重复的,但实际上不是。只是一点点不同,不断重复。Git 不停地告诉我: “请告诉我你是谁”,即使是在设置好之后。当我运行 git commit,这是我得到的... 。

$ git commit


*** Please tell me who you are.


Run


git config --global user.email "you@example.com"


git config --global user.name "Your Name"


to set your account's default identity.
Omit --global to set the identity only in this repository.


fatal: unable to auto-detect email address (got 'Obby@ObbyWorkstation.(none)')

但是当我运行 git config --global -l的时候,它会给我所有的细节..。

$ git config --global -l
user.name=myname
user.mail=me.myself@gmail.com
http.proxy=proxy.XX.XX.XX:XXXX

我已经更改了我的名称、电子邮件和代理,但是当我运行命令时,它们看起来很好,即使在。Gitconfig 文件,我可以看到设置的值。什么可能是失去的东西,因为我不能承诺在所有。每次它都问我是谁?

@ sheu 告诉我一些事情,我改变了,但仍然是同样的问题。当我设置 --local,仍然 git commit问我同样的问题。这是输出

$ git config --local -l
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly
user.name=myname
user.mail=me.myself@gmail.com
145790 次浏览

You're setting the global git options, but the local checkout possibly has overrides set. Try setting them again with git config --local <setting> <value>. You can look at the .git/config file in your local checkout to see what local settings the checkout has defined.

That’s a typo. You’ve accidently set user.mail with no e in email. Fix it by setting user.email in the global configuration with

git config --global user.email "you@example.com"

Do you have a local user.name or user.email that's overriding the global one?

git config --list --global | grep user
user.name=YOUR NAME
user.email=YOUR@EMAIL
git config --list --local | grep user
user.name=YOUR NAME
user.email=

If so, remove them

git config --unset --local user.name
git config --unset --local user.email

The local settings are per-clone, so you'll have to unset the local user.name and user.email for each of the repos on your machine.

I had this problem even after setting the config properly. git config

My scenario was issuing git command through supervisor (in Linux). On further debugging, supervisor was not reading the git config from home folder. Hence, I had to set the environment HOME variable in the supervisor config so that it can locate the git config correctly. It's strange that supervisor was not able to locate the git config just from the username configured in supervisor's config (/etc/supervisor/conf.d).