Migrating a repository from one GitHub Enterprise Organization to another is different from migrating a repository from a personal GitHub account to another personal account due to organizational controls, permissions, security measures, and automation settings.
Feature | GitHub Enterprise Org to Org | Personal GitHub to Another Personal GitHub |
---|---|---|
Repository Transfer | Possible via UI-based transfer or manual code migration | Simple push from one GitHub account to another |
Secrets Handling | Secrets are NOT transferred | Secrets are NOT transferred |
GitHub Actions Workflows | Need to verify actions, secrets, and permissions | Workflows remain but require secrets to be reconfigured |
Commit History | Retained in both approaches | Retained in both approaches |
Self-Hosted Runners | Need to be manually reconfigured | Not applicable unless self-hosted runners are used |
Permissions Required | Admin access to both orgs | Write access to both repos |
-
Go to Source Organization Repo:
- Navigate to the repository in the old GitHub Enterprise Organization.
-
Initiate Transfer:
- Click Settings → Danger Zone → Transfer Repository.
- Enter the new organization name (
new-org-name/repo-name
). - Confirm the transfer.
-
Post-Transfer Steps:
- The repository is removed from the old organization and appears in the new organization.
- Secrets are NOT transferred and must be re-added manually.
- Self-hosted runners must be reconfigured if applicable.
❌ Does the old repository remain? No, it is moved completely.
❌ Are GitHub Actions secrets transferred? No, they must be manually re-added.
❌ Are workflow run logs transferred? No, old workflow logs are not available.
✅ Is commit history retained? Yes, commit history remains intact.
# Clone the Old Repository Locally
git clone --bare https://github.com/old-org/repo-name.git
cd repo-name.git
# Push the Repository to the New Organization
git push --mirror https://github.com/new-org/repo-name.git
- Set Up GitHub Actions and Secrets Again:
- Re-add repository secrets manually (Settings → Secrets and Variables → Actions).
- Verify and update GitHub Actions YAML files in
.github/workflows/
. - If using self-hosted runners, reconfigure them in the new organization.
- Run on your local machine.
- You need Admin or Write Access to both repositories.
Task | Required Permission |
---|---|
Clone the repository | Read access to the old repository |
Push to new organization | Write/Admin access to new repository |
Transfer repository (UI method) | Admin access in both organizations |
- Secrets do NOT get transferred.
- Go to Settings → Secrets and Variables → Actions in the new repo and manually re-add them.
- If using organization-level secrets, ensure they are available in the new organization.
- Look for hardcoded tokens in the repository files.
- Check the GitHub Actions workflows (
.github/workflows/*.yml
) for any references to environment variables. - Use GitHub Secret Scanning or search for
GITHUB_TOKEN
,PAT
,ACCESS_TOKEN
in the codebase.
- Self-Hosted Runners:
- If self-hosted runners were used, they must be re-registered in the new organization.
- Navigate to Settings → Actions → Runners to set them up again.
- GitHub-Hosted Runners:
- No manual configuration needed unless there are specific restrictions in place.
-
Backup the Old Repository First:
- Use
git clone --bare
to ensure you have a copy of the repository.
- Use
-
Migrate Using Code-Based Approach (Recommended):
- Allows easy rollback if something goes wrong.
- Ensures that a copy of the old repository remains accessible.
-
Document All Secrets and Configurations Before Migration:
- Extract the list of existing secrets (names only, values are not visible).
- Ensure GitHub Actions and environment variables are well-documented.
-
Verify GitHub Actions and Runners in the New Organization:
- Manually re-add secrets.
- Check if self-hosted runners need re-registration.
- Run test workflows to confirm everything is working.
- Yes, GitHub Enterprise offers a 30-day free trial (for business accounts).
- Sign up here: GitHub Enterprise Trial.
- If you want to test, use GitHub Free or Pro accounts for a mock migration.
- Create a personal repository on GitHub.
- Push it to another personal account using the same migration steps.
- Test workflows, secrets, and permissions in the new repo.
- If organization-level testing is needed, use GitHub Team Plan ($4/month).
- GitHub API-Based Migration: Use GitHub REST API or GraphQL for automation.
- GitHub Enterprise Importer (Beta): GitHub provides an official repository migration tool for enterprise customers.
- Third-Party Migration Tools: Tools like
ghe-migrator
for large-scale GitHub Enterprise migrations.
- Use the code-based approach for a safer migration.
- Manually verify secrets and GitHub Actions after migration.
- Test the migration first in a personal repository before handling an enterprise migration.
- Document everything, including secrets, runners, and permissions, before starting the migration.
This document covers all aspects of GitHub Enterprise repository migration. Let me know if you need any additional details! 🚀