Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Unable to obtain your identity" error in Git

Tags:

git

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
like image 793
user3361043 Avatar asked Aug 20 '14 21:08

user3361043


1 Answers

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.

like image 119
phihag Avatar answered Sep 27 '22 20:09

phihag