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

In this guide

Importing projects from Mercurial

  1. SSH into your GitHub Enterprise instance:

    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.

  6. Change the current working directory to your local repository.

  7. Push the imported repository to GitHub Enterprise:

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

Importing projects from Subversion

  1. SSH into your GitHub Enterprise instance:

    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.

  6. Change the current working directory to your local repository.

  7. Push the imported repository to GitHub Enterprise:

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

Importing projects from Team Foundation Version Control

  1. SSH into your GitHub Enterprise instance:

    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.

  6. Change the current working directory to your local repository.

  7. Push the imported repository to GitHub Enterprise:

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

Further reading