This site requires JavaScript to be enabled
An updated version of this article is available

Migrating Git Repositories to Penn State's GitHub Enterprise Cloud

330 views

12.0 - Updated on 10-03-2024 by Justin Elliott (jde6)

11.0 - Updated on 10-02-2024 by Gretchen Kuwahara (gzk2)

10.0 - Updated on 09-05-2024 by Justin Elliott (jde6)

9.0 - Updated on 06-18-2024 by Justin Elliott (jde6)

8.0 - Updated on 04-05-2024 by Justin Elliott (jde6)

7.0 - Updated on 04-05-2024 by Justin Elliott (jde6)

6.0 - Updated on 03-25-2024 by Justin Elliott (jde6)

5.0 - Updated on 03-25-2024 by Justin Elliott (jde6)

4.0 - Updated on 03-25-2024 by Justin Elliott (jde6)

3.0 - Updated on 03-25-2024 by Justin Elliott (jde6)

2.0 - Updated on 03-25-2024 by Justin Elliott (jde6)

1.0 - Authored on 02-27-2024 by Justin Elliott (jde6)

 
Penn State students, faculty and staff who wish to use Penn State's GitHub Enterprise Cloud.
 

Introduction

To make the process of migrating Git repositories to GitHub.com easier from other source code repository services (ie, git.psu.edu), Github.com provides a basic GitHub Importer tool. This tool works well for basic repositories. For more information please visit Github's About GitHub's migration tooling page.
 
For highly complex repositories hosted on alternative services, additional open-source migration tools exist. However, this guide focuses on GitHub's importer tool due to its user-friendliness and suitability for most common migration scenarios.
 

Easiest Method

 
The easiest way to migrate a single repo from another Git repo hosting service is below.
 
  1. In GitHub create a new empty repo, so that it has no files (no README.md). See GitHub's documentation for more details.
  2. On your local Git client (Git GUI client or command line) do a git pull from the current git origin host. Confirm that all branches and tags have been pulled.
  3. Get the Github clone url. See GitHub's documentation for more details.
  4. Update your local Git repo origin with the new GitHub repo clone url. See GitHub's documentation for more details.
  5. One you local Git client (git) push your local repo to the (now new) GitHub origin repo url.
  6. Login to github.com and check that the new repo has all of the repo branches and tags.
 

Optional: Use GitHub's Import Repo Tool

Below is an example of how to use GitHub's import tool to import a private git repo from GitLab. For this example of importing from GitLab you'll first need to create a read-only "Private Access Token". We recommend that you use the method detailed above first, and then if it doesn't fit your workflow, then try this process below.
 
  1. Login to git.psu.edu
  2. On the left side click the icon of your user to display the "User settings"
  3. On the left side click "Access Tokens"
  4. Under "Personal Access Tokens" click "Add new token"
  5. In the "Token name" field enter in "github-import"
  6. Update the "Expiration date" to at least 1 day ahead
  7. Under the "Select scopes" section select "read_repository"
  8. Click the "Create personal access token" button
  9. Immediately copy and save the new token in the "Your new personal access token" field as you will not be able to access it again!
Now that your private access token has been completed we will use the GitHub importer tool:
 
  1. Login to GitHub.com with your GitHub.com account that is associated with your Penn State GitHub.com account.
  2. Once logged in click the "Import repository" Link on the left side
  3. At the top select the organization you want to import into, ie, "psu-edu"
  4. Authenticate to Penn State SSO
  5. In the "Your old repository's clone URL*" field enter the path to your repo, ie: "https://git.psu.edu/teamname/projectname/repo"
  6. Change the "Owner" to your GitHub User id. Once the repo has been successfully import you will transfer it to the correct org and team.
  7. In the "Repository name" field enter in the name for the repo as it will exist in GitHub.com.
  8. Leave the default visibility to "Private"
  9. Click the "Begin import" button.
  10. The GitHub importer tool will start the "Preparing your new repository" process...
    1. The import tool will state something similar to ...
      1. "Your old project requires credentials for read-only access. We will only temporarily store them for importing. When importing from Azure DevOps, please use a personal access token with read access to the repository being imported."
    2. In the "Login" field enter in your Penn State access ID.
    3. In the "Private Access Token" paste in the new personal access token created above.
  11. Click the "Submit" button to start the import process.
  12. The Tool will attempt to login to git.psu.edu with your read-only personal access token, identify the Git hosting service, optimize the repo, and then once it's successfully imported it will report that the importing process has completed and provide a link for your newly imported repository!
  13. Soon after the above step you should see an automated email from noreply@github.com with the email subject of "Import to githubuser/reponame is finished!"

Recommended Next Steps

  1. You should next test and confirm that you are able to clone the repo from github.
  2. If the repository is just for your use you are done!
  3. If the repository is for a team you'll want to create a GitHub Team in your Organization.
    1. Once the team is created you can transfer the repo to the Team.
    2. On Github.com you can click or search for the name of the migrated repository on the left side
    3. Once you're on the repository page select "Settings" on the upper right
    4. On the left side click "General" (Default)
    5. Scroll down to the "Danger Zone" section
    6. In the "Transfer ownership" section click the "Transfer" button
    7. Change the "Select an organization" button and select the org which contains the Team you want to move the repository to. You may be asked to re-authenticate with Penn State's SSO.
    8. In the "New owner*" field select the organization the repository should be in (ie, "psu-edu")
    9. In the "Repository name" field enter in the new repo name (If you need to change it)
    10. In the "Type githubuser/reponame to confirm" field copy the "githubuser/reponame" text and paste it in the field.
    11. Lastly, click the "I understand, transfer this repository." button to complete the transfer process.
    12. Next, in the "Team Access" section select the team that should have access to the repository.
    13. Click the "Transfer" button.
    14. Navigate to the Teams of the organization (ie, "https://github.com/orgs/psu-edu/teams" ) to confirm that you see the repository is now under the "Repositories" area.
    15. You may want to further adjust the permissions on the repository by selecting it from the repository list and on the right side change the pop up menu from "Read" to one of the other options (which includes details on what access rights are changed / permitted).
    16. Soon after the above steps have been completed you should receive an email from noreply@github.com with a subject similar to "[GitHub] Repository transfer from @githubuser (githubuser/reponame)"

Archive the old Repository

Once you've confirmed that the repository can be cloned and committed to successfully on github.com you may want to archive it on the old code hosting service. Below is an example of how that would be done in GitLab.

  1. Login to git.psu.edu
  2. Go to the repo page
  3. On the left side click "Settings"
    1. If you don't see "Settings" you may need to make your browser window wider or click the sidebar icon to display it.
  4. Click "General"
  5. On the right panel in the "Advanced" section click the "Expand" button
  6. Scroll down to the "Archive project" section and click the "Archive project" button
  7. When prompted with "Are you sure that you want to archive this project?" click the "Archive project" button
  8. The repo page will reload and now display "Archived project! Repository and other project resources are read-only"

Optional: Revoke Your Personal Access Token

After you've completed importing repos to Github.com you may want to delete your personal access token (which is read-only and expires soon, so this is optional).

  1. Login to git.psu.edu
  2. On the left side click "Access Tokens"
  3. Under the "Active personal access tokens" section find the row of the token that you created above and under the "Action" column ,click the Trash can ("Revoke") icon.
  4. When prompted with "Are you sure you want to revoke the personal access token "github-import"? This action cannot be undone." click the "Revoke" button.