18

Is there any way to change the Git username and email for Xcode? When I try commit now it will post my real name. I want it to post my GitHub username so that you can link commits to my user on GitHub.

Usually with Git I've been able to just type git config --global user.name whoosh in the terminal but it doesn't seem to work on Mac and Xcode.

Amit Joshi
  • 15,448
  • 21
  • 77
  • 141
whoosy
  • 297
  • 2
  • 4
  • 10
  • Kinda semi-related: does GitHub not allow user name/email aliases like BitBucket does for example? +1 on your question anyway as I have no idea how to do it either. – Filip Radelic Sep 08 '12 at 23:18
  • https://help.github.com/articles/setting-your-email-in-git / Changing the following changed the username even when pushing to a remote github repo from Xcode. – Mark McCorkle Feb 11 '13 at 23:29
  • I gave answer on this link [find easy solution](http://stackoverflow.com/questions/41561391/why-all-my-xcode-commits-to-bitbucket-show-other-user-author-name-on-bitbucket/41561543#41561543) – Tejinder Jan 10 '17 at 06:06
  • I gave a simple answer here [find answer](http://stackoverflow.com/questions/41561391/why-all-my-xcode-commits-to-bitbucket-show-other-user-author-name-on-bitbucket/41561543#41561543) – Tejinder Jan 10 '17 at 06:07

4 Answers4

26

The following terminal commands works for me:

xcrun git config --global user.name 'new_user_name'
xcrun git config --global user.email 'new@email.com'

These are to update user name and e-mail respectively.

After execution of that commands successive commits to Git via Xcode will use the data specified in it.

sergtk
  • 10,714
  • 15
  • 75
  • 130
11

As mentioned in "Where is the Git commit info set in Xcode 4?", XCode takes user information from your contact card from your (2012) Address Book (called Contact in 2014).

Changing your contact card would change user information (for new commits)


Update 2014 (2 years later), as illustrated in sergtk's answer, XCode (5+) now supports the git config user.name and user.email.
That will fill out:

XCode user.name/user.email

Using xcrun before the git config commands allows to locate or invoke coexistence- and platform-aware developer tools from the command-line.
(assuming the Xcode Command-line Tools is up-to-date)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
6

Since I have multiple projects with different commit names, the solution provided by @sergtk does not work for me. Instead, I did the following:

xcrun git config --local user.name 'new_user_name'
xcrun git config --local user.email 'new@email.com'

Also, note that the first commit needs to be changed, so I used the solution provided here to fix this: Change the author and committer name and e-mail of multiple commits in Git

Community
  • 1
  • 1
Greeso
  • 7,544
  • 9
  • 51
  • 77
0

I start working from corporate mac and had the same problem with bitbacket repository. Any answers didn't help me. Neither removing previous user from address book and saving my own nor terminal commands. One day I tried to work with new repo from SourceTree (free soft from Atlassian). I have replaced user name and mail with my own in preferences and all was ok. I had commits with my own credentials. Ye! I hope my solving will be useful!

Hot'n'Young
  • 491
  • 4
  • 12