Skip to main content
We publish frequent updates to our documentation, and translation of this page may still be in progress. For the most current information, please visit the English documentation.

此版本的 GitHub Enterprise 已停止服务 2023-03-15. 即使针对重大安全问题,也不会发布补丁。 为了获得更好的性能、更高的安全性和新功能,请升级到最新版本的 GitHub Enterprise。 如需升级帮助,请联系 GitHub Enterprise 支持

Exporting migration data from GitHub.com

You can export migration data from an organization on GitHub.com by using the API to select repositories to migrate, then generating a migration archive that you can import into a GitHub Enterprise Server instance.

Preparing the source organization on GitHub

  1. Ensure that you have owner permissions on the source organization's repositories.

  2. 生成具有 repoadmin:org 作用域的访问令牌 on GitHub.com.

  3. 为尽量减少停机,请创建要从源实例导出的仓库列表。 您可以使用每行列出一个仓库 URL 的文本文件一次性导出多个仓库。

Exporting the organization's repositories

注意:分支关系在迁移后不会持续。

To export repository data from GitHub.com, use the Migrations API.

The Migrations API is currently in a preview period, which means that the endpoints and parameters may change in the future.

Generating a migration archive

注意:锁定存储库会阻止对存储库的所有写入访问。 您不能将新团队或协作者与锁定的仓库相关联。

如果您执行的试用版,则无需锁定仓库。 从正在使用的存储库迁移数据时,GitHub 强烈建议锁定存储库。 有关详细信息,请参阅“About ghe-migrator”。

  1. Notify members of your organization that you'll be performing a migration. The export can take several minutes, depending on the number of repositories being exported. The full migration including import may take several hours so we recommend doing a trial run in order to determine how long the full process will take. For more information, see "About ghe-migrator."

  2. Start a migration by sending a POST request to the migration endpoint. You'll need:

    • Your access token for authentication.
    • A list of the repositories you want to migrate:
      curl -H "Authorization: Bearer GITHUB_ACCESS_TOKEN" \
      -X POST \
      -H "Accept: application/vnd.github+json" \
      -d'{"lock_repositories":true,"repositories":["ORG_NAME/REPO_NAME", "ORG_NAME/REPO_NAME"]}' \
      https://api.github.com/orgs/ORG_NAME/migrations
    • If you want to lock the repositories before migrating them, make sure lock_repositories is set to true. This is highly recommended.
    • You can exclude file attachments by passing exclude_attachments: true to the endpoint. 文件附件可能很大,可能不必要地胀大您的最终迁移存档。 The final archive size must be less than 20 GB.

    This request returns a unique id which represents your migration. You'll need it for subsequent calls to the Migrations API.

  3. Send a GET request to the migration status endpoint to fetch the status of a migration. You'll need:

    • Your access token for authentication.
    • The unique id of the migration:
      curl -H "Authorization: Bearer GITHUB_ACCESS_TOKEN" \
      -H "Accept: application/vnd.github+json" \
      https://api.github.com/orgs/ORG_NAME/migrations/ID

    A migration can be in one of the following states:

    • pending, which means the migration hasn't started yet.
    • exporting, which means the migration is in progress.
    • exported, which means the migration finished successfully.
    • failed, which means the migration failed.
  4. After your migration has exported, download the migration archive by sending a GET request to the migration download endpoint. You'll need:

    • Your access token for authentication.
    • The unique id of the migration:
      curl -H "Authorization: Bearer GITHUB_ACCESS_TOKEN" \
      -H "Accept: application/vnd.github+json" \
      -L -o migration_archive.tar.gz \
      https://api.github.com/orgs/ORG_NAME/migrations/ID/archive
  5. The migration archive is automatically deleted after seven days. If you would prefer to delete it sooner, you can send a DELETE request to the migration archive delete endpoint. You'll need:

    • Your access token for authentication.
    • The unique id of the migration:
      curl -H "Authorization: Bearer GITHUB_ACCESS_TOKEN" \
      -X DELETE \
      -H "Accept: application/vnd.github+json" \
      https://api.github.com/orgs/ORG_NAME/migrations/ID/archive
  6. 若要准备存档的迁移数据以导入到 GitHub Enterprise Server 实例中,请参阅“准备将数据迁移到企业”。