Skip to main content

This version of GitHub Enterprise was discontinued on 2022-06-03. No patch releases will be made, even for critical security issues. For better performance, improved security, and new features, upgrade to the latest version of GitHub Enterprise. For help with the upgrade, contact GitHub Enterprise support.

Importing data from third-party version control systems

Using the git-import suite of tools, you can import from Subversion, Mercurial and Team Foundation Version Control to Git repositories on GitHub Enterprise Server.

Importing projects from Mercurial

  1. SSH into your GitHub Enterprise Server instance. For more information, see "Accessing the administrative 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. Review the comma-separated (CSV) file in /PATH/REPO-NAME.git/git-import/raw-authors.csv. It should contain these columns:

    • ID: The author as stored in the original repository, followed by a unique identifier
    • NAME: The author as stored in the original repository

    To map authors from the original repository to an email address and name, create a new CSV file with the columns ID,(ignored),GIT_EMAIL,GIT_NAME, which replaces the author information for anything by "ID" with "GIT_EMAIL" and "GIT_NAME".

    Example:

    • Original author ID: octocat@111111-2222-3333-4444-55555555555

    • New email address: octocat@github.com

    • New name: The Octocat

      To map the original author to the new Git user, the CSV file should include the line:

      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. Change the current working directory to your local repository.

  7. Push the imported repository to GitHub Enterprise Server:

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

Importing projects from Subversion

  1. SSH into your GitHub Enterprise Server instance. For more information, see "Accessing the administrative 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. Review the comma-separated (CSV) file in /PATH/REPO-NAME.git/git-import/raw-authors.csv. It should contain these columns:

    • ID: The author as stored in the original repository, followed by a unique identifier
    • NAME: The author as stored in the original repository

    To map authors from the original repository to an email address and name, create a new CSV file with the columns ID,(ignored),GIT_EMAIL,GIT_NAME, which replaces the author information for anything by "ID" with "GIT_EMAIL" and "GIT_NAME".

    Example:

    • Original author ID: octocat@111111-2222-3333-4444-55555555555

    • New email address: octocat@github.com

    • New name: The Octocat

      To map the original author to the new Git user, the CSV file should include the line:

      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. Change the current working directory to your local repository.

  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 into your GitHub Enterprise Server instance. For more information, see "Accessing the administrative 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. Review the comma-separated (CSV) file in /PATH/REPO-NAME.git/git-import/raw-authors.csv. It should contain these columns:

    • ID: The author as stored in the original repository, followed by a unique identifier
    • NAME: The author as stored in the original repository

    To map authors from the original repository to an email address and name, create a new CSV file with the columns ID,(ignored),GIT_EMAIL,GIT_NAME, which replaces the author information for anything by "ID" with "GIT_EMAIL" and "GIT_NAME".

    Example:

    • Original author ID: octocat@111111-2222-3333-4444-55555555555

    • New email address: octocat@github.com

    • New name: The Octocat

      To map the original author to the new Git user, the CSV file should include the line:

      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. Change the current working directory to your local repository.

  7. Push the imported repository to GitHub Enterprise Server:

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

Further reading