github - Git won't use second set of credentials when pushing to remote -


i've setup second git identity use company account, creating second ssh key , adding config file ~/.ssh directory, explained in blog post:

i have set new user name , email of local repository:

$(path repo directory) git config user.name "<company account user name>" $(path repo directory) git config user.email "<company account user email>" 

as suggested in 1 of comments in blog post.

i've created local repository, , 1 on github (company account). i've added (public) repo on github remote (origin) of local one.

i can pull remote, (using either command line , sourcetree), when try push, error:

error: permission <company user name>/test.git denied <personal user name>. fatal: not read remote repository. 

that is, git trying push using existing, personal account, not new, work one.

how can have git push using proper account's credentials?

i think whole osx keychain/keychain helper thingy might blame.

here how solved it:

1) delete local repo ("start scratch").

2) clone again origin (github).

3) check repo configured use new account's e-mail address (it was).

4) check again hosts in .ssh/config file, make sure each set proper key (they were).

5) out of desperation, assign new rsa key both accounts/hosts in said .ssh/config file. still can't push, , still being addressed old account's e-mail address (something's being cached somewhere...), hence can't authenticate.

6) launch keychain access.app, search "git", "github" , delete "internet password" entries. <- did trick

after deleting everything, had re-enter credentials both accounts when prompted (sourcetree), have 2 (working) repositories using 2 different github accounts, side side on same machine.

hope helps someone.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -