同一台电脑上有多个github帐号?(Multiple github accounts on the same computer?)

编程入门 行业动态 更新时间:2024-10-28 08:25:47
同一台电脑上有多个github帐号?(Multiple github accounts on the same computer?)

试图从我的计算机上处​​理我的实际“工作”资料,以及我对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/.gitconfig

And then your work specific config ~/work/.gitconfig would look like this:

[user] email = pavan.kataria@company.tld

Thank you @alexg for informing me of this in the comments.

更多推荐

本文发布于:2023-04-29 11:32:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1336247.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   上有   帐号   一台电脑   github

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!