Migrate Repos to Cloud#
Repositories can be migrated from the on-prem (GHES) environment to the cloud (GHEC). There are two basic methods, both have to be done on a per-repo basis. One is to just move the 'git data', which includes Branches and Commit history but not things like Pull Requests or Issues or reference to users that took those actions. This is the simplest method. The second more involved option will move all the 'github data' as well (PRs and Issues, etc).
Migrate using the browser importer tool#
Log into github.com and follow these directions. This will leave the original repository in place so you will need to manually delete it.
- Enter the URL for the repository; copied from the browser is fine
- The importer will ask for a username and password
- Username
- Enter your University email
- Password
- Generate a personal access token on github.umn.edu to use for the password
- Username
Migrate using the CLI#
Migrating a repo and its data requires the user to either be an Organization owner on both GHES and GHEC orgs respectively or have the 'migrate' role.
The following are steps to migrate a single repository at a time using DevEx-managed Azure Blob storage already configured on github.umn.edu.
- This will not remove the repo from the on-prem server
- This method migrates the git data along with most of the github data, such as PRs, wikis, projects, issues, etc
Steps#
- Create a classic PAT (personal access token) on github.umn.edu, then paste it somewhere you can reference it later
- Scopes to set on both PATs
- Note: the minimum scopes work for GitHub Enterprise Server (repo, admin:org, and workflow), but the scopes needed for GitHub.com are basically everything except delete_repo and delete:packages
- Scopes to set on both PATs
- Repeat Step 1, but on GitHub.com
- After you save the PAT, click Configure SSO to Authorize the token on your organization
- Install the github cli wherever you want to run the commands
- GitHub: Installing the CLI
- This has been tested on RHEL9 VMs from Hosting Team
- Add the GEI extention to the cli by running
gh extension install github/gh-gei
- GitHub: Using the GitHub Enterprise Importer extension
- When you are asked to
gh auth login
, choose 'Github.com' and then the following:- What is your preferred protocol for Git operations on this host?: HTTPS
- Authenticate Git with your GitHub credentials?: Yes
- How would you like to authenticate GitHub CLI?: Paste an authentication token, then provide it a token; it should be the same token as generated above on GitHub.com
- Log in to github.umn.edu from the CLI
- Run
gh auth login
again, but this time choose 'GitHub Enterprise Server' and provide the GH_SOURCE_PAT contents
- Run
- Set environmental variables
- Run the following code snippet, replacing the SOURCE, CURRENT-NAME, DESTINATION, and NEW-NAME with your orgs and repository names:
gh gei migrate-repo --github-source-org SOURCE --source-repo CURRENT-NAME --github-target-org DESTINATION --target-repo NEW-NAME --ghes-api-url https://github.umn.edu/api/v3
Reclaim Mannequins#
When you first migrate your repos, previous commits will be shown as committed by Mannequins. To link your github.com user to your previous github.umn.edu commits, follow These Instructions.
Contact Info#
For assistance email devex@umn.edu.