我成功设置了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
答案 0 :(得分:6)
cd your project
git config --local user.name "your name"
git config --local user.email "your email"
我做到了。
答案 1 :(得分:5)
您正在使用sudo
运行git。在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@
。
答案 2 :(得分:1)
1-打开您的git终端
在您的git bash中2输入 git config --list
3-显示完整的git数据
4-检查您的
user.name =您的名字
user.email =您的电子邮件ID
5-如果数据不正确,请使用
更新git config --local user.name“您的用户名”
git config --local user.email“您的电子邮件”
答案 3 :(得分:0)
打开cmd进入您的GIT仓库
cd your project
git config --global user.email "your email registered with GIT"
git config --global user.name "your GIT user name"
保持空格不变。否则,它将经历相同的错误。
答案 4 :(得分:0)
git config --local user.name“您的名字”
git config --local user.email“ your@gmail.com”