Migration
Cross-Platform Git Migration
Migrate repositories between GitHub, GitLab, Bitbucket, and other Git hosting platforms while preserving full commit history and all refs.
- Teams migrating from SVN or Hg to Git
- Basic knowledge of SVN or Hg operations
- Basic Git experience
- Author information lost or mis-mapped after migration
- Large files not handled, causing repository bloat after migration
Citations & Further Reading
- Migrations [Discussion]
- docs.gitlab.com — Import [Blog]
What you will learn
- Understand the core purpose of Cross-Platform Git Migration
- Master the basic usage and common options of Cross-Platform Git Migration
- Migrate repositories between GitHub, GitLab, Bitbucket, and other Git hosting platforms while preserving full commit history and all refs.
- Understand key concepts: Overview
- Know when to use this feature and when to avoid it
Start with a problem
Your team is migrating from another version control system to Git, or moving code and history between different Git platforms. You're worried about losing commit history or author information during the process.
Overview
Migrating between Git hosting platforms is straightforward at the Git level — the underlying protocol is the same. The key is transferring all refs (branches, tags, PR/MR metadata).
Core Migration Methods
Method 1: Bare Mirror (Recommended)
# 1. Create a mirror clone from the source
git clone --mirror https://github.com/old-org/repo.git
cd repo.git
# 2. Push to the target platform
git remote set-url origin https://gitlab.com/new-org/repo.git
git push --mirror origin
# 3. Verify
git log --oneline --all
--mirror clones all refs including branches, tags, and notes — the most complete transfer.
Method 2: Direct Push
# If you already have a full local clone
git remote add new-origin https://gitlab.com/new-org/repo.git
git push --all new-origin # All branches
git push --tags new-origin # All tags
Method 3: Multi-Platform Sync (Ongoing)
# Configure multiple remotes
git remote add github https://github.com/org/repo.git
git remote add gitlab https://gitlab.com/org/repo.git
git remote add bitbucket https://bitbucket.org/org/repo.git
# Push to all remotes
git push --all github
git push --all gitlab
git push --all bitbucket
Migrating PRs / Merge Requests
PRs/MRs are platform-level metadata, not Git objects — they can't be transferred with git push --mirror.
GitHub → GitHub
# Use GitHub's official migration tool
gh repo migrate <source-repo> --target-owner <target-org>
GitHub → GitLab
- Create a new project in GitLab
- Select Import project → GitHub
- Authorize GitLab to access GitHub
- Choose the repository to import
GitLab → GitHub
- Click + → Import repository on GitHub
- Enter the GitLab repo's Git URL
- GitHub imports the history automatically
Metadata Migration Map
| Metadata | GitHub | GitLab | Migration |
|---|---|---|---|
| Commit history | ✅ | ✅ | git push --mirror |
| Branches | ✅ | ✅ | git push --mirror |
| Tags | ✅ | ✅ | git push --mirror |
| PRs/MRs | ✅ | ✅ | Platform tools (cross-platform not supported) |
| Issues | ✅ | ✅ | API migration scripts |
| Wiki | ✅ | ✅ | Separate repo migration |
| CI config | ❌ | ❌ | Must rebuild manually |
Post-Migration Checklist
# 1. Verify ref integrity
git for-each-ref --format='%(refname)' | sort
# 2. Check key branches
git branch -a
# 3. Verify tags
git tag -l
# 4. Confirm remote association
git remote -v
Try it yourself
- Practice the platform-migration command in a test repository and observe state changes before and after
- Experiment with different options and compare the output differences
- Simulate a real scenario where you would need to use this, and walk through the full process
Continue Learning
migration/svn-to-git— SVN to Git migrationmigration/hg-to-git— Mercurial to Git migrationhosting/platform-comparison— Platform comparison
Further reading
Keep going on the same topic: