Skip to main content

转让仓库

您可以将仓库转让给其他用户或组织帐户。

About repository transfers

When you transfer a repository to a new owner, they can immediately administer the repository's contents, issues, pull requests, releases, projects (classic), and settings. You can also change the repository name while transferring a repository. For more information, see "Renaming a repository."

Prerequisites for repository transfers:

  • When you transfer a repository that you own to another personal account, the new owner will receive a confirmation email. The confirmation email includes instructions for accepting the transfer. If the new owner doesn't accept the transfer within one day, the invitation will expire.
  • To transfer a repository that you own to an organization, you must have permission to create a repository in the target organization.
  • The target account must not have a repository with the same name, or a fork in the same network.
  • The original owner of the repository is added as a collaborator on the transferred repository. Other collaborators to the transferred repository remain intact.
  • Single repositories forked from a private upstream network cannot be transferred.

If you transfer a private repository to a GitHub Free user or organization account, the repository will lose access to features like protected branches and GitHub Pages. For more information, see "GitHub’s plans."

If the transferred repository contains an action listed on GitHub Marketplace, or had more than 100 clones or more than 100 uses of GitHub Actions in the week prior to the transfer, GitHub permanently retires the owner name and repository name combination (OWNER/REPOSITORY-NAME) when you transfer the repository. If you try to create a repository using a retired owner name and repository name combination, you will see the error: "The repository REPOSITORY_NAME has been retired and cannot be reused."

What's transferred with a repository?

When you transfer a repository, its issues, pull requests, wiki, stars, and watchers are also transferred. If the transferred repository contains webhooks, services, secrets, or deploy keys, they will remain associated after the transfer is complete. Git information about commits, including contributions, is preserved. In addition:

  • If the transferred repository is a fork, then it remains associated with the upstream repository.

  • If the transferred repository has any forks, then those forks will remain associated with the repository after the transfer is complete.

  • If the transferred repository uses Git Large File Storage, all Git LFS objects are automatically moved. This transfer occurs in the background, so if you have a large number of Git LFS objects or if the Git LFS objects themselves are large, it may take some time for the transfer to occur. Before you transfer a repository that uses Git LFS, make sure the receiving account has enough data packs to store the Git LFS objects you'll be moving over. For more information on adding storage for personal accounts, see "Upgrading Git Large File Storage."

  • When a repository is transferred between two personal accounts, issue assignments are left intact. When you transfer a repository from a personal account to an organization, issues assigned to members in the organization remain intact, and all other issue assignees are cleared. Only owners in the organization are allowed to create new issue assignments. When you transfer a repository from an organization to a personal account, only issues assigned to the repository's owner are kept, and all other issue assignees are removed.

  • If the transferred repository contains a GitHub Pages site, then links to the Git repository on the Web and through Git activity are redirected. However, we don't redirect GitHub Pages associated with the repository.

  • All links to the previous repository location are automatically redirected to the new location. When you use git clone, git fetch, or git push on a transferred repository, these commands will redirect to the new repository location or URL. However, to avoid confusion, we strongly recommend updating any existing local clones to point to the new repository URL. You can do this by using git remote on the command line:

    git remote set-url origin NEW_URL
    

    Warning: If you create a new repository or fork at the previous repository location, the redirects to the transferred repository will be deactivated. They can be reactivated by renaming or deleting the new repository or fork.

  • When you transfer a repository from an organization to a personal account, the repository's read-only collaborators will not be transferred. This is because collaborators can't have read-only access to repositories owned by a personal account. For more information about repository permission levels, see "Permission levels for a personal account repository" and "Repository roles for an organization."

  • Sponsors who have access to the repository through a sponsorship tier may be affected. For more information, see "Managing your sponsorship tiers".

  • Packages associated with the repository may be transferred, or may lose their link to the repository, depending on the registry they belong to. For more information, see "About permissions for GitHub Packages."

For more information, see "Managing remote repositories."

Repository transfers and organizations

To transfer repositories to an organization, you must have repository creation permissions in the receiving organization. If organization owners have disabled repository creation by organization members, only organization owners can transfer repositories out of or into the organization.

Once a repository is transferred to an organization, the organization's default repository permission settings and default membership privileges will apply to the transferred repository.

Transferring a repository owned by your personal account

You can transfer your repository to any personal account that accepts your repository transfer. When a repository is transferred between two personal accounts, the original repository owner and collaborators are automatically added as collaborators to the new repository.

If you published a GitHub Pages site in a private repository and added a custom domain, before transferring the repository, you may want to remove or update your DNS records to avoid the risk of a domain takeover. For more information, see "Managing a custom domain for your GitHub Pages site."

  1. On GitHub.com, navigate to the main page of the repository.

  2. Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.

    Screenshot of a repository header showing the tabs. The "Settings" tab is highlighted by a dark orange outline.

  3. At the bottom of the page, in the "Danger Zone" section, click Transfer.

  4. Read the information about transferring a repository, then, under "New owner", choose how to specify the new owner.

    • To choose one of your organizations, select Select one of my organizations.

      • Select the dropdown menu and click an organization.

      • Optionally, in the "Repository name" field, type a new name for the repository.

        Note: You must be an owner of the target organization to rename the repository.

    • To specify an organization or username, select Specify an organization or username, then type the organization name or the new owner's username.

  5. Read the warnings about potential loss of features depending on the new owner's GitHub subscription.

  6. Following Type REPOSITORY NAME to confirm, type the name of the repository you'd like to transfer, then click I understand, transfer this repository.

Transferring a repository owned by your organization

If you have owner permissions in an organization or admin permissions to one of its repositories, you can transfer a repository owned by your organization to your personal account or to another organization.

  1. Sign into your personal account that has admin or owner permissions in the organization that owns the repository.

  2. On GitHub.com, navigate to the main page of the repository.

  3. Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.

    Screenshot of a repository header showing the tabs. The "Settings" tab is highlighted by a dark orange outline.

  4. At the bottom of the page, in the "Danger Zone" section, click Transfer.

  5. Read the information about transferring a repository, then, under "New owner", choose how to specify the new owner.

    • To choose one of your organizations, select Select one of my organizations.

      • Select the dropdown menu and click an organization.

      • Optionally, in the "Repository name" field, type a new name for the repository.

        Note: You must be an owner of the target organization to rename the repository.

    • To specify an organization or username, select Specify an organization or username, then type the organization name or the new owner's username.

  6. Read the warnings about potential loss of features depending on the new owner's GitHub subscription.

  7. Following Type REPOSITORY NAME to confirm, type the name of the repository you'd like to transfer, then click I understand, transfer this repository.