This site requires JavaScript to be enabled

Penn State GitHub - Migrating Git Repositories

1660 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 Service.
 

Introduction

To make the process of migrating Git repositories to GitHub.com easier from other source code repository services (like git.psu.edu), below are two methods we recommend. The first one is to make a "bare" (no files) repo in GitHub, git pull everything (branches and tags) from the current (old) git origin, update the origin to the new git repo, and the push the repo to the new repo in GitHub.
 
The second is to use Github's 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) execute a git pull from the current git origin host. Confirm that all branches, latest commits, 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. On your 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, latest commits 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 you wish to make the repository available to others please visit our Penn State GitHub - How to Restrict Access to Repositories article for more information.
  4. Penn State GitLab users should follow our Migrating from GitLab to GitHub - Decommissioning your GitLab project article for information on archiving and decommissioning projects.

Additional Information

Signing up for Penn State's GitHub Service

Migrating from GitLab to GitHub - Getting Started

Penn State GitHub - Frequently Asked Questions

GitHub Glossary