我成功设置了user.email和user.name,但每当我尝试提交repo时,Git仍会显示一条错误消息,说明它无法识别我的身份.可能有什么不对?
这是git config --list
打印出来的命令:
user.name=myname
user.email=myemail@myemail.com
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
Run Code Online (Sandbox Code Playgroud)
编辑:错误读取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
Run Code Online (Sandbox Code Playgroud)
cat .git/config
输出:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[gui]
wmstate = normal
geometry = 1855x1026+65+24 262 188
Run Code Online (Sandbox Code Playgroud)
小智 7
cd your project
git config --local user.name "your name"
git config --local user.email "your email"
Run Code Online (Sandbox Code Playgroud)
我做到了.
你正在运行git sudo
.在sudo环境中,$HOME
因此git配置将不存在.不用运行git sudo
.
对于感兴趣的人,这里是如何重现问题:
$ 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)')
Run Code Online (Sandbox Code Playgroud)
请注意root@
自动检测到的电子邮件地址.