Introduction
Easiest Method
- In GitHub create a new empty repo, so that it has no files (no README.md). See GitHub's documentation for more details.
- 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.
- Get the Github clone url. See GitHub's documentation for more details.
- Update your local Git repo origin with the new GitHub repo clone url. See GitHub's documentation for more details.
- On your local Git client (git) push your local repo to the (now new) GitHub origin repo url.
- 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
- Login to git.psu.edu
- On the left side click the icon of your user to display the "User settings"
- On the left side click "Access Tokens"
- Under "Personal Access Tokens" click "Add new token"
- In the "Token name" field enter in "github-import"
- Update the "Expiration date" to at least 1 day ahead
- Under the "Select scopes" section select "read_repository"
- Click the "Create personal access token" button
- 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!
- Login to GitHub.com with your GitHub.com account that is associated with your Penn State GitHub.com account.
- Once logged in click the "Import repository" Link on the left side
- At the top select the organization you want to import into, ie, "psu-edu"
- Authenticate to Penn State SSO
- In the "Your old repository's clone URL*" field enter the path to your repo, ie: "https://git.psu.edu/teamname/projectname/repo"
- 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.
- In the "Repository name" field enter in the name for the repo as it will exist in GitHub.com.
- Leave the default visibility to "Private"
- Click the "Begin import" button.
- The GitHub importer tool will start the "Preparing your new repository" process...
- The import tool will state something similar to ...
- "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."
- In the "Login" field enter in your Penn State access ID.
- In the "Private Access Token" paste in the new personal access token created above.
- The import tool will state something similar to ...
- Click the "Submit" button to start the import process.
- 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!
- 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
- You should next test and confirm that you are able to clone the repo from github.
- If the repository is just for your use you are done!
- If you wish to make the repository available to others please visit our Penn State GitHub Enterprise Cloud - How to Restrict Access to Repositories article for more information.
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.
- Login to git.psu.edu
- Go to the repo page
- On the left side click "Settings"
- If you don't see "Settings" you may need to make your browser window wider or click the sidebar icon to display it.
- Click "General"
- On the right panel in the "Advanced" section click the "Expand" button
- Scroll down to the "Archive project" section and click the "Archive project" button
- When prompted with "Are you sure that you want to archive this project?" click the "Archive project" button
- 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).
- Login to git.psu.edu
- On the left side click "Access Tokens"
- 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.
- 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.