Skip to main content
我们经常发布文档更新,此页面的翻译可能仍在进行中。 有关最新信息,请访问英语文档

Importing from other version control systems with the administrative shell

Using the administrative shell, you can import from Subversion, Mercurial and Team Foundation Version Control to Git repositories on GitHub Enterprise Server.

谁可以使用此功能

Site administrators can use the administrative shell to import data from other version control systems.

Importing projects from Mercurial

  1. 通过 SSH 连接到 你的 GitHub Enterprise Server 实例。 如果实例包含多个节点,例如,如果配置了高可用性或异地复制,则通过 SSH 连接到主节点。 如果使用群集,则可以通过 SSH 连接到任何节点。 有关 SSH 访问权限的详细信息,请参阅“访问管理 shell (SSH)”。

    $ ssh -p 122 admin@HOSTNAME
  2. Make a raw clone of the project using the command below, specifying the URL of the source project, and a path to a temporary repository:

    $ git-import-hg-raw HG-CLONE-URL/PATH/REPO-NAME.git
    # Creates a new repository with one or more Git refs in "refs/import/" in the specified path.
  3. 查看 /PATH/REPO-NAME.git/git-import/raw-authors.csv 中的逗号分隔 (CSV) 文件。 它应包含以下三列:

    • ID:存储在原始存储库中的作者,后接唯一识别符。
    • NAME:原始存储库中存储的作者

    要将作者从原始存储库映射到电子邮件地址和名称,请使用 ID,(ignored),GIT_EMAIL,GIT_NAME 列新建一个 CSV 文件,将用“ID”表示的任何作者信息替换为“GIT_EMAIL”和“GIT_NAME”。

    示例:

    • 原始作者 ID:octocat@111111-2222-3333-4444-55555555555

    • 新电子邮件地址:octocat@github.com

    • 新名称:The Octocat

      要将原始作者映射到新 Git 用户,CSV 文件应包含行:

      octocat@111111-2222-3333-4444-55555555555, ,octocat@github.com,The Octocat

  4. Rewrite the authors and branches using the CSV file:

    $ git-import-rewrite --flavor hg --authors /PATH/AUTHORS-MAP-FILE.csv /PATH/REPO-NAME.git
  5. If you haven't yet, create a new empty repository on GitHub Enterprise Server.

  6. 将当前工作目录更改为您的本地仓库。

  7. Push the imported repository to GitHub Enterprise Server:

    $ git push --mirror PUSH-URL-ON-GITHUB-ENTERPRISE

Importing projects from Subversion

  1. 通过 SSH 连接到 你的 GitHub Enterprise Server 实例。 如果实例包含多个节点,例如,如果配置了高可用性或异地复制,则通过 SSH 连接到主节点。 如果使用群集,则可以通过 SSH 连接到任何节点。 有关 SSH 访问权限的详细信息,请参阅“访问管理 shell (SSH)”。

    $ ssh -p 122 admin@HOSTNAME
  2. Make a raw clone of the project using the command below, specifying the URL of the source project, and a path to a temporary repository:

    $ git-import-svn-raw SVN-CLONE-URL /PATH/REPO-NAME.git
    # Creates a new repository with one or more Git refs in "refs/import/" in the specified path.
  3. 查看 /PATH/REPO-NAME.git/git-import/raw-authors.csv 中的逗号分隔 (CSV) 文件。 它应包含以下三列:

    • ID:存储在原始存储库中的作者,后接唯一识别符。
    • NAME:原始存储库中存储的作者

    要将作者从原始存储库映射到电子邮件地址和名称,请使用 ID,(ignored),GIT_EMAIL,GIT_NAME 列新建一个 CSV 文件,将用“ID”表示的任何作者信息替换为“GIT_EMAIL”和“GIT_NAME”。

    示例:

    • 原始作者 ID:octocat@111111-2222-3333-4444-55555555555

    • 新电子邮件地址:octocat@github.com

    • 新名称:The Octocat

      要将原始作者映射到新 Git 用户,CSV 文件应包含行:

      octocat@111111-2222-3333-4444-55555555555, ,octocat@github.com,The Octocat

  4. Rewrite the authors and branches using the CSV file:

    $ git-import-rewrite --flavor svn --authors /PATH/AUTHORS-MAP-FILE.csv /PATH/REPO-NAME.git
  5. If you haven't yet, create a new empty repository on GitHub Enterprise Server.

  6. 将当前工作目录更改为您的本地仓库。

  7. Push the imported repository to GitHub Enterprise Server:

    $ git push --mirror PUSH-URL-ON-GITHUB-ENTERPRISE

Importing projects from Team Foundation Version Control

  1. 通过 SSH 连接到 你的 GitHub Enterprise Server 实例。 如果实例包含多个节点,例如,如果配置了高可用性或异地复制,则通过 SSH 连接到主节点。 如果使用群集,则可以通过 SSH 连接到任何节点。 有关 SSH 访问权限的详细信息,请参阅“访问管理 shell (SSH)”。

    $ ssh -p 122 admin@HOSTNAME
  2. Make a raw clone of the project using the command below, specifying the URL of the source project, and a path to a temporary repository:

    $ git-import-tfs-raw TEAM-FOUNDATION-CLONE-URL /PATH/REPO-NAME.git
    # Creates a new repository with one or more Git refs in "refs/import/" in the specified path.
  3. 查看 /PATH/REPO-NAME.git/git-import/raw-authors.csv 中的逗号分隔 (CSV) 文件。 它应包含以下三列:

    • ID:存储在原始存储库中的作者,后接唯一识别符。
    • NAME:原始存储库中存储的作者

    要将作者从原始存储库映射到电子邮件地址和名称,请使用 ID,(ignored),GIT_EMAIL,GIT_NAME 列新建一个 CSV 文件,将用“ID”表示的任何作者信息替换为“GIT_EMAIL”和“GIT_NAME”。

    示例:

    • 原始作者 ID:octocat@111111-2222-3333-4444-55555555555

    • 新电子邮件地址:octocat@github.com

    • 新名称:The Octocat

      要将原始作者映射到新 Git 用户,CSV 文件应包含行:

      octocat@111111-2222-3333-4444-55555555555, ,octocat@github.com,The Octocat

  4. Rewrite the authors and branches using the CSV file:

    $ git-import-rewrite --flavor tfs --authors /PATH/AUTHORS-MAP-FILE.csv /PATH/REPO_NAME.git
  5. If you haven't yet, create a new empty repository on GitHub Enterprise Server.

  6. 将当前工作目录更改为您的本地仓库。

  7. Push the imported repository to GitHub Enterprise Server:

    $ git push --mirror PUSH-URL-ON-GITHUB-ENTERPRISE

Further reading