为什么 Git 不允许我在配置后提交?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14662526/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 15:25:00  来源:igfitidea点击:

Why Git is not allowing me to commit even after configuration?

gitgithubcommitconfig

提问by Obby

This question seems like a duplicate but it's really not. Just a slight difference that keeps on repeating. git keeps on telling me: "please tell me who you are", even after setting it up. when I run git commit, this is what I get....

这个问题似乎是重复的,但实际上不是。只是不断重复的细微差别。git 一直告诉我:“请告诉我你是谁”,即使在设置之后也是如此。当我跑步时git commit,这就是我得到的......

$ git commit

*** Please tell me who you are.

Run

git config --global user.email "[email protected]"

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)')

But when I run git config --global -l, it gives me all my details...

但是当我跑的时候git config --global -l,它给了我所有的细节......

$ git config --global -l
user.name=myname
[email protected]
http.proxy=proxy.XX.XX.XX:XXXX

I have changed my name, email and proxy but they are appearing fine when I run the command, even in the .gitconfig file I can see the values are set. what could be the missing thing, because I cannot commit at all. Every time it keeps asking me who I am ?

我已经更改了我的姓名、电子邮件和代理,但是当我运行命令时它们看起来很好,即使在 .gitconfig 文件中我也可以看到设置的值。可能缺少什么,因为我根本无法提交。每次它一直问我我是谁?

@sheu told me something that i changed, but still the same problem. when i set --local, still git commitasks me the same question. this is the output

@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
[email protected]

回答by Lumen

That's a typo. You've accidently set user.mailwith no e. Fix it by setting user.emailin the global configuration with

那是一个错字。你不小心设置user.mail了没有e。通过user.email在全局配置中设置来修复它

git config --global user.email "[email protected]"

回答by sheu

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/configfile in your local checkout to see what local settings the checkout has defined.

您正在设置全局 git 选项,但本地结帐可能设置了覆盖。尝试使用 再次设置它们git config --local <setting> <value>。您可以查看.git/config本地结帐中的文件,以了解结帐定义了哪些本地设置。

回答by Nate

Do you have a local user.nameor user.emailthat's overriding the global one?

你有本地的user.name还是user.email覆盖全球的?

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.nameand user.emailfor each of the repos on your machine.

本地设置是针对每个克隆的,因此您必须取消设置本地user.nameuser.email机器上的每个存储库。