UTK Github: Migration from GitHub.com Enterprise Cloud to EMU

Tags Github

Overview

Documentation on the migration process for moving GitHub resources from GitHub Enterprise Cloud to GitHub Enterprise Managed Users.

Instructions

Step 1: Install the GEI extension of the GitHub CLI

  • Install WinGet with “winget install --id GitHub.cli” inside CMD
    • The file path will most likely be “C:\Program Files\GitHub CLI”
  • Install the GEI extension with “gh extension install github/gh-gei”
  • Command Prompt window showing installation of the GitHub CLI GEI extension with the gh extension install github/gh-gei command, followed by the prompt to run gh auth login, where the user proceeds to authenticate with a GitHub Enterprise account as part of the migration setup.
  • Run “gh auth login” and login with your GitHub.com (Non-EMU) account, not EMU account
    • Select GitHub.com
    • Select HTTPS or your preferred protocol for Git operations
    • Select Yes to authenticate Git with your credentials
    • Login with a web browser to authenticate GitHub CLI
  • Command Prompt window showing the gh auth login process in the GitHub CLI, where the user selects GitHub.com, chooses HTTPS for Git operations, confirms credential authentication, and proceeds to log in with a web browser to authenticate the CLI using a non‑EMU GitHub account.

Step 2: Update the GEI extension of the GitHub CLI

  • Open PowerShell and navigate to the same file path where GitHub CLI is installed
  • Update the GEI extension with “.\gh extension upgrade github/gh-gei”

Step 3: Set environment variables

  • Create personal access tokens for both source and destination organizations
  • For the destination token, go to your EMU instance
    • Go to Settings -> Developer Settings -> Personal access tokens -> Tokens (classic) -> Generate a new token (classic)
    • Scope the token to repo, workflow, and admin:org
    • Then Generate token
  • For the source token (Non-EMU), only check repo and admin:org
  • GitHub Personal access tokens (classic) settings page showing the Generate new token (classic) option, where the user creates tokens for migration by selecting scopes—repo and admin:org for the source (non‑EMU) account, and repo, workflow, and admin:org for the destination (EMU) account.
  • GitHub New personal access token (classic) page showing fields for Token name and Expiration, with required scopes selected—repo, workflow, and admin:org—where the user reviews permissions before generating the token.
  • Next, click Configure SSO to authorize both tokens to their respective organizations
  • GitHub Personal access tokens (classic) page showing an existing token with the Configure SSO button selected, opening the Single sign‑on organizations panel where the user authorizes the token for the required organizations.
  • Set the environment variables for the tokens using these commands in PowerShell:
    • $env:GH_PAT="TOKEN"
    • $env:GH_SOURCE_PAT="TOKEN"

Step 4: Generate a migration script

  • For a single repo migration, input the following command and replace each field with the required names of source/destination orgs, etc:

.\gh gei migrate-repo --github-source-org "SOURCE" --source-repo "CURRENT-NAME" --github-target-org "DESTINATION" --target-repo "NEW-NAME" --target-repo-visibility “{internal or private}”

  • NOTE: This will begin the migration so make sure everything is edited correctly
  • Queue messages and Progress messages will pop up.  This will take a minimum of ~4 mins to complete.
  • Once the migration is complete, you may skip the final step.
  • For multiple repos, input the following command:

.\gh gei generate-script --github-source-org “SOURCE” --github-target-org “DESTINATION” --output “FILENAME”.ps1

  • If you want the script to download the migration log for each migrated repository, add the “--download-migration-logs” flag.
  • If there are any repositories you don't want to migrate, delete or comment out the corresponding lines.
  • If you want any repositories to have a different name in the destination organization, update the value for the corresponding “--target-repo” flag.

Step 5: Migrate repositories

  • For a single repo, the above command should have already run and migrated the repo to the destination org.
  • For multiple repos, check to make sure the PowerShell script downloaded to “C:\Program Files\GitHub CLI” and edit any changes to the script (in Notepad)
    • To run the script in PowerShell, type “.\FILENAME”   
    • Ex.(“PS C:\Program Files\GitHub CLI> .\FILENAME”)
  • Queue messages and Progress messages will pop up.  This will take a minimum of ~4 mins to complete.