4

I have two GitHub accounts on the same Mac. And have credential-osxkeychain installed. It works fine with my first GitHub account. But, how can I add the second account into the keychain access? If it is not possible, how can I 'logout' my first account?

P.S. I can't use SSH key on my network.

P.S. I have already set git config user.name & git config user.email at the second repo. Error 403 show up when I git push. Github didn't ask me for the password of the second account. I think git is pushing the repo with the wrong account & password.

user1597243
  • 51
  • 1
  • 4
  • I know it's possible to configure a single repository with git config --local for a particular user. But there must be another way. –  Sep 07 '12 at 19:59
  • I have set the ```git config user.name``` & ```git config user.email``` for that repo. But I got error 403 when I push it. –  Sep 08 '12 at 10:28
  • 3
    user.name and user.email have nothing to do with authentication, these are just values which are recorded during commit. – knittl Sep 08 '12 at 12:23
  • then how to add another account to authentication? – user1597243 Sep 08 '12 at 18:34
  • Why do you even need two github accounts? FWIW authentication is done via the push url (which is normally starting with `ssh://`) – knittl Sep 08 '12 at 18:44

2 Answers2

1

If you're trying to use SSH authentication, Github is probably seeing the first ssh key and associating it with the first account, then denying that account access to the second account's repos. I suggest switching one or both of the accounts to http based access.

For example, over SSH my repo URL would be: git@github.com:opie4624/repoA.git while the HTTP equivalent would be: https://github.com/opie4624/repoA.git.

When pushing or pulling with the HTTP url, git will prompt for the username and password allowing you to specify which of the two Github accounts to use. That also saves you from mucking about with ssh keys.

Hope this helps!

akraut
  • 311
  • 1
  • 3
  • 17
1

Lastly, I go to Keychain Access and delete/modify the entry of github.com. Thus, I can login another account when pushing.

user1597243
  • 51
  • 1
  • 4