Multiple Github Accounts With Git In Windows

梦想的初衷 提交于 2019-12-06 05:00:45

Clearing the git entries in the windows credential manager did not resolve this issue.

If you are using ssh URL (git@github.com:<user>/<repo>), the credential manager is not involved: it provides credentials for https:// URLS only.

Use git for the first time which asks for github credentials when pushing to a repository.

That would be the case only if the remote origin URL is an https one.

So the goal would be to push changes to multiple github accounts without having to do things like temporarily specify the ssh key to use.

That is done through an ssh config file: see as practical examples:


From the edit

Host user1
 HostName github.com
 User git
 IdentityFile ~/.ssh/iser1_key  <<====
Host user2
 HostName github.com
 User git
 IdentityFile ~/.ssh/user1_key  <<==== same key!? Meaning same user!

you cannot expect push as user2, if the SSH config for user2 entry refers to user1 private key.

Per the conversation with VonC you can clearly see in the ssh config file the identity file for the second user was incorrect as it pointed to the first users file. The second entry was copied from the first and this value was not changed.

After modifying the value to point to the correct key i.e. ~/.ssh/schwaggs_key I could clone and push without issue. As a side note I have to set the user's email and name properties in git for each repository pulled from each user i.e once inside the repo,

git config user.email "github account email"

git config user.name "github account username"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!