git 如何合并两个github帐户

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37693255/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:15:01  来源:igfitidea点击:

How to merge two github accounts

gitgithub

提问by Rodrigo Curbelo

I have two GitHub accounts, one of this was created a long time ago at my work and has an username that refers to the company where I work. I have another account which is my personal GitHub account that I can't stop using. Could I merge the two accounts so I can work in only one of these?

我有两个 GitHub 帐户,其中一个是很久以前在我的工作中创建的,其用户名是指我工作的公司。我有另一个帐户,这是我无法停止使用的个人 GitHub 帐户。我可以合并这两个帐户以便我只能在其中一个帐户中工作吗?

采纳答案by Mohammad Fareed

Merging 2 accounts is not possible at github, you can transfer ownership to your personal account.

在 github 上无法合并 2 个帐户,您可以将所有权转移到您的个人帐户。

goto  >> Setting >>Transfer ownership 

For more details : https://help.github.com/articles/merging-multiple-user-accounts/

更多详情:https: //help.github.com/articles/merging-multiple-user-accounts/

回答by Scott Mathson

Responding with updated answer here (relevant in 2019).

在此处回复更新的答案(与 2019 年相关)。

Luckily this is a relatively quick process to 1) transfer repo ownership, 2) manage (add/remove/change) account email addresses, and 3) keep/transfer mostcommit history to the profile's contribution graph.

幸运的是,这是一个相对较快的过程,可以1) 转移回购所有权2) 管理(添加/删除/更改)帐户电子邮件地址,以及3) 保留/转移大多数提交历史到个人资料的贡献图

Transferring repository ownershiponly requires a few steps.

转移存储库所有权只需要几个步骤。

  • From Repo > Settings page > Options > scroll to the bottom, looking for red-colored “Transfer” button within the “Danger Zone”
  • Fill out the required fields, typing the name of the repository to confirm and entering the new owner's GH username
  • New owner receives an email with an auth token that expires after 24 hours. Be sure to check that email for the account you're transferring to and follow the link to fully complete any repo transfers
  • 从回购 > 设置页面 > 选项 > 滚动到底部,在“危险区域”中寻找红色的“转移”按钮
  • 填写必填字段,输入仓库名称进行确认并输入新所有者的 GH 用户名
  • 新所有者收到一封电子邮件,其中包含 24 小时后过期的身份验证令牌。请务必检查您要转移到的帐户的电子邮件,并按照链接完全完成任何回购转移

Repo transfers between accounts includes all issues, pull requests, forks, stars, alongside automatic redirects being setup for git and http. Though you should update your remote's origin URL once the transfer is complete: git remote set-url origin new_url

帐户之间的回购转移包括所有问题、拉取请求、分叉、星号,以及为 git 和 http 设置的自动重定向。尽管您应该在传输完成后更新遥控器的原始 URL:git remote set-url origin new_url

Git commit history, SAML, and other items are tied to the email(s) you have on-file within GitHub and in your remote, local setup. Keeping/transferring commit history to contribution graph comes when you add original, authoring email/verify iton user account you're consolidating/merging into.

Git 提交历史、SAML 和其他项目与您在 GitHub 和远程本地设置中存档的电子邮件相关联。当您在要合并/合并到的用户帐户上添加原始、创作电子邮件/验证它时,会将提交历史记录保留/转移到贡献图。

  • From GH dashboard > Click your profile photo dropdown > Settings page
  • Click on Emails in the left sidebar > Add email address field > Add new email
  • Check your inbox for the email address you've just added and click the link included. You should land on your GitHub dashboard, seeing an email verification confirmation banner
  • 从 GH 仪表板 > 单击您的个人资料照片下拉菜单 > 设置页面
  • 单击左侧边栏中的电子邮件 > 添加电子邮件地址字段 > 添加新电子邮件
  • 检查您刚刚添加的电子邮件地址的收件箱,然后单击包含的链接。您应该登陆您的 GitHub 仪表板,看到电子邮件验证确认横幅

Previous note about mosthistory transferring is referring to PRs and issues which fall under this "grey area" of history and will not transfer when combining accounts.

之前关于大多数历史转移的说明是指 PR 和属于历史“灰色区域”的问题,并且在合并帐户时不会转移。

After you've added email to GH user account + verified it, most commit history will transfer. Allow GitHub a bit of time to propagate the history and contributions between accounts.

在您将电子邮件添加到 GH 用户帐户并对其进行验证后,大多数提交历史将转移。给 GitHub 一点时间在帐户之间传播历史和贡献。

You will lose commits tied to original pull requests and issues histories tied to account you're removing. These “...would instead be attributed to our “Ghost” user once the account is deleted, though the issues/PRs themselves would otherwise be unaffected.” (from GH Support). If you're looking to read more, I wrote up a quick blog article for this with steps and visuals on transferring repo ownership, adding emails, and more - how to merge/combine two (or many) GitHub user accounts.

您将丢失与原始拉取请求相关的提交以及与您要删除的帐户相关的问题历史记录。这些“ ......一旦帐户被删除,将改为归因于我们的“幽灵”用户,尽管问题/PR 本身不会受到影响。” (来自 GH 支持)。如果您想阅读更多内容,我为此写了一篇快速博客文章,其中包含有关转移存储库所有权、添加电子邮件等的步骤和视觉效果 -如何合并/组合两个(或多个)GitHub 用户帐户

GitHub does recommend using one user account for personal and professional (work) repositories (source), definitely consider doing so!

GitHub 确实建议将一个用户帐户用于个人和专业(工作)存储库(),请务必考虑这样做!

Managing multiple user accounts can be cumbersome, though there are ways to simplify workflow of multiple accounts, though, so in the case this response wasn't for you and you want to keep your many accounts as-is, see how to manage multiple GH accounts on one machine with SSH keys.

管理多个用户帐户可能很麻烦,尽管有一些方法可以简化多个帐户的工作流程,但是,如果此响应不适合您并且您希望保持多个帐户不变,请参阅如何管理多个 GH使用 SSH 密钥在一台机器上的帐户

回答by Vlad Didenko

While Github outlines a limited "Merging multiple user accounts" process, which is also mentioned in previous answers, it is not a complete solution. It does not resolve ownership in third party repositories contributions.

虽然 Github 概述了一个有限的“合并多个用户帐户”过程,这在之前的答案中也有提到,但它并不是一个完整的解决方案。它不解决第三方存储库贡献的所有权。

GitHub will display comments from a deleted user (which will be the account you got rid of following GitHub's account merge suggestion) as "ghost" user's comments - without attributing them to the surviving account. See some more details here:

GitHub 会将来自已删除用户的评论(这将是您按照 GitHub 的帐户合并建议删除的帐户)显示为“幽灵”用户的评论 - 而不会将它们归因于幸存的帐户。在此处查看更多详细信息:

https://help.github.com/articles/deleting-your-user-account/

https://help.github.com/articles/deleting-your-user-account/

So in reality as of November 2016 there is no general way to fully merge allcontributions from one account to another.

因此,实际上截至 2016 年 11 月,没有通用的方法可以将一个帐户的所有捐款完全合并到另一个帐户。

回答by Samuel Marks

GitHub has a convenient command-line tool: hubfound at https://hub.github.com

GitHub 有一个方便的命令行工具:hub位于https://hub.github.com

I've written an example to move all repos from all your organisations to my_new_organisation_name:

我编写了一个示例,将所有存储库从您的所有组织移至my_new_organisation_name

#!/usr/bin/env bash

orgs="$(hub api '/user/orgs' | jq -r '.[] | .login')";
repos="$(for org in $orgs; do hub api '/orgs/'"$org"'/repos' | jq -r '.[] | .name';
         done)"

for org in $orgs; do
    for repo in $repos; do
        ( hub api '/repos/'"$org"'/'"$repo"'/transfer'
                  -F 'new_owner'='my_new_organisation_name' | jq . ) &
    done
done

For users rather than organisation, set my_new_organisation_nameto the replacement username, remove the outer loop, and replace the repos=line with:

对于用户而不是组织,设置my_new_organisation_name为替换用户名,删除外部循环,并将该repos=行替换为:

repos="$(hub api /users/SamuelMarks/repos | jq -r '.[] | .name')"

EDIT: Found a GUIif you prefer https://stackoverflow.com/a/54549899

编辑:如果您喜欢https://stackoverflow.com/a/54549899,请找到一个GUI