20

Whenever I try to commit, using source control in Xcode, I get an error that I need to configure my email address and name (it seems to read my email address incorrectly). I went to the Terminal, and entered them (again). The error didn't go away.

I can commit normally in Terminal, but not in Xcode. Is there a way to fix it? Or enter the configuration info directly in Xcode?

This is the error message:

*** 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 'myemail@gmail-1040826.(none)')

Here's my .gitconfig (I replaced my actual name with "My Name", and my username with "myname" for privacy reasons):

myname-1040826:Project myname$ git config -l
user.email=myname@gmail.com
user.name=My Name
filter.media.clean=git-media-clean %f
filter.media.smudge=git-media-smudge %f
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
submodule.PeerKit.url=https://github.com/jpsim/PeerKit.git
codersl
  • 2,222
  • 4
  • 30
  • 33
coopersita
  • 5,011
  • 3
  • 27
  • 48
  • What does your `.gitconfig` actually look like? – matt Sep 12 '15 at 22:21
  • @matt I added the results of `git config -l` – coopersita Sep 12 '15 at 22:36
  • 1
    Looks okay to me, though what do I know? Just out of curiosity, is that `git config --global --list` or `git config --local --list`? — Also, boy, I sure wonder whether the submodule has something to do with it. I find those tricky... Try just making a new project with a local git repo and see if you can commit to _that_. If so, you know it's just this one project that's problematic. – matt Sep 12 '15 at 23:06
  • 2
    That was really helpful, @matt. I was doing `git config -l`, but when I did `git config --local --list`, the name and email are not listed, so I added name and email locally (I had just tried to do it globally), and now it works. Thanks! – coopersita Sep 13 '15 at 00:02
  • Woohoo! I've never used a local config file, so I wasn't sure what would happen. You'd think you'd just inherit missing elements from the global config file, but I guess not. – matt Sep 13 '15 at 00:16
  • @matt, It's Xcode 7. The same project in Xcode 6 didn't give me this issue, and GIT in the Terminal worked fine. – coopersita Sep 13 '15 at 02:18
  • Oooh, right. This sounds like a bug report should be in order, then. – matt Sep 13 '15 at 03:09
  • @matt I'll do as you suggested, and see if it happens in other projects, and if it does, I'll file a bug report. And thanks again for the help. – coopersita Sep 13 '15 at 03:57
  • And don't forget to answer your own question! You've hit on something interesting. – matt Sep 13 '15 at 04:00
  • 1
    I am having a similar problem with xcode7 GM. git was working fine with Xcode 6. git still works fine in terminal, i can commit both locally and to the remote. But in Xcode it says authentication fails and it is impossible to reset the username. – mflac Sep 13 '15 at 16:26
  • @mflac You may want to open a new question, and post the complete error message and your confg file contents. – coopersita Sep 13 '15 at 16:40
  • you're right. I ended up doing that. [Xcode 7 GM can not authenticate git repository](http://stackoverflow.com/questions/32552213/xcode-7-gm-can-not-authenticate-git-repository) – mflac Sep 13 '15 at 20:36
  • I had this issue just now while travelling, turns out the username used for the commit tries to incorporate the hostname of the machine which is being derived from the network connection. For whatever reason, this particular network causes the resulting username to get munged into something git doesn't like. Disabling WiFi temporarily and retrying the commit resolved the issue for me. – Tim Kane Jun 18 '16 at 23:52

2 Answers2

18

It looks like Xcode is not reading global GIT settings. If you encounter this issue, set your name and email to the specific project via the Terminal:

git config user.email "you@example.com" 
git config user.name "Your Name"

Note: Make sure you are in the project's directory when you do the above.

coopersita
  • 5,011
  • 3
  • 27
  • 48
6

It's not only the matter in global settings, the real problem are local ones.

Try this.

cd your/project/directory
git config --local user.email "your@email.com"
git config --local user.name "yourName"

This worked for me.