试图从我的计算机上处理我的实际“工作”资料,以及我对git中心的个人资料。
工作账户首先设立,一切都完美无缺。
然而,我的个人账户似乎不能推到我的个人回购,这是在不同的帐户/电子邮件下设置的。
我已经尝试将我的工作密钥复制到我的个人帐户,但这会引发错误,因为当然一个密钥只能附加到一个帐户。
如何从他们各自的github凭据推/拉两个帐户?
Trying to work on my both my actual "work" repos, and my personal repos on git hub, from my computer.
The work account was set up first, and everything works flawlessly.
My personal account, however cannot seem to push to my personal repo, which is set up under a different account/email.
I've tried copying my work key up to my personal account, but that throws an error, because of course a key can be only attached to one account.
How can I push/pull to and from both accounts, from their respective github credentials?
最满意答案
所有您需要做的是配置您的SSH设置与多个SSH密钥层。
这个链接很简单(谢谢Eric): http : //code.tutsplus.com/tutorials/quick-tip-how-to-work-with-github-and-multiple-accounts--net-22574
生成SSH密钥(Win / msysgit) https://help.github.com/articles/generating-an-ssh-key/
另外,如果您使用多个存储库使用不同的角色,您需要确保您的各个存储库的用户设置相应地被覆盖:
设置用户名,电子邮件和GitHub令牌 - 个别回覆的覆盖设置https://help.github.com/articles/setting-your-email-in-git/
希望这可以帮助。
编辑:更新链接
All you need to do is configure your SSH setup with multiple SSH keypairs.
This link is easy to follow (Thanks Eric): http://code.tutsplus.com/tutorials/quick-tip-how-to-work-with-github-and-multiple-accounts--net-22574
Generating SSH keys (Win/msysgit) https://help.github.com/articles/generating-an-ssh-key/
Also, if you're working with multiple repositories using different personas, you need to make sure that your individual repositories have the user settings overridden accordingly:
Setting user name, email and GitHub token – Overriding settings for individual repos https://help.github.com/articles/setting-your-commit-email-address-in-git/
Hope this helps.
Note: Some of you may require different emails to be used for different repositories, from git 2.13 you can set the email on a directory basis by editing the global config file found at: ~/.gitconfig using conditionals like so:
[user] name = Pavan Kataria email = defaultemail@gmail.com [includeIf "gitdir:~/work/"] path = ~/work/.gitconfigAnd then your work specific config ~/work/.gitconfig would look like this:
[user] email = pavan.kataria@company.tldThank you @alexg for informing me of this in the comments.
更多推荐
发布评论