I set up user.email and user.name successfully, but whenever I try to commit to a repo Git still displays an error saying that it can't recognize my identity. What could be wrong?
This is what git config --list
command prints out:
user.name=myname
[email protected]
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
Edit: Error reads Unable to obtain your identity: *** 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 identity only in this repository. fatal: unable to auto-detect email address (got 'root@computername.'(none))
cat ~/.gitconfig
command outputs this:
[user]
name = myname
email = [email protected]
cat .git/config
outputs this:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[gui]
wmstate = normal
geometry = 1855x1026+65+24 262 188
You are running git with sudo
. In a sudo environment, $HOME
and therefore the git configuration will not be present. Run git without sudo
.
For the interested, here's how to reproduce the problem:
$ mkdir repo
$ cd repo
$ git init
Initialized empty Git repository in /home/phihag/repo/.git/
$ git config --global user.email "[email protected]"
$ git config --global user.name "My Name"
$ sudo git commit -m first
*** 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 'root@t4.(none)')
Notice the root@
in the automatically detected email address.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With