我设置了 user.email 并成功 user.name,但是每当我尝试提交存储库时,Git 仍然会显示一个错误,说它无法识别我的身份。可能出了什么问题?
这是git config --list
命令打印的内容:
user.name=myname
user.email=myemail@myemail.com
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
编辑:错误读取Unable to obtain your identity: *** 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 identity only in this repository. fatal: unable to auto-detect email address (got 'root@computername.'(none))
cat ~/.gitconfig
命令输出以下内容:
[user]
name = myname
email = myemail@myemail.com
cat .git/config
输出以下内容:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[gui]
wmstate = normal
geometry = 1855x1026+65+24 262 188
cd your project
git config --local user.name "your name"
git config --local user.email "your email"
我成功了。
你正在运行 git 与 sudo
.在 sudo 环境中,$HOME
,因此 git 配置将不存在。在没有sudo
的情况下运行 git .
对于感兴趣的人,以下是重现问题的方法:
$ mkdir repo
$ cd repo
$ git init
Initialized empty Git repository in /home/phihag/repo/.git/
$ git config --global user.email "me@example.com"
$ git config --global user.name "My Name"
$ sudo git commit -m first
*** 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 'root@t4.(none)')
请注意自动检测到的电子邮件地址中的root@
。
1-打开你的 git 终端
2-输入 git 配置 --list in your git bash
3-它显示您的完整 git 数据
4-检查您的
user.name= 你的名字
user.email=您的电子邮件ID
5-如果数据不正确,请使用更新
git config --local user.name "Your username">
git config --local user.email "你的电子邮件">
打开 cmd 转到您的 GIT 存储库
cd your project
git config --global user.email "your email registered with GIT"
git config --global user.name "your GIT user name"
保持空间不变。否则,它将通过相同的错误。
- 在这里打开你的 git bash。
- 然后粘贴它
git config --local user.name "你的名字">
git config --local user.email "your@gmail.com">
如果使用上述解决方案无法解决您的问题,请考虑使用:
git config --replace-all user.email "you@domain.com"
git config --replace-all user.name "your_name"