Video in progress

Staff 🌿 Git

The company wants to move 300 repos from a self-hosted GitLab to GitHub. Besides the Git history, what moves, what does not, and how do you plan it?

The Git part is easy: branches and tags move completely with a mirror clone. The hard part is the platform: MRs and comments, CI pipelines, permissions, webhooks, branch protection, LFS, package registries and secrets. I start with an inventory, then move with a pilot and waves.

📖 Answer

There is a trap in the Git part too. git push --mirror sends all refs, including GitLab's refs/merge-requests/*. GitHub manages refs/pull/* itself and may not accept such refs. So I push explicitly:

git clone --mirror https://gitlab.shop.uz/billing/invoice.git
cd invoice.git
git push https://github.com/shop/invoice.git 'refs/heads/*:refs/heads/*' 'refs/tags/*:refs/tags/*'
git lfs fetch --all && git lfs push --all https://github.com/shop/invoice.git

What stays outside Git:

  • MR history and review comments. The platforms have import tools, but I check what they move on a pilot repo first. For audit, the old system is kept read-only for a set period;
  • CI. .gitlab-ci.yml → GitHub Actions is a rewrite, together with runners, caches and secrets. Most of the time goes here;
  • Permissions and protection. Groups → teams, protected branches → rulesets. CODEOWNERS syntax is similar but not identical;
  • Integrations. Webhooks, deploy keys, Jira links, Maven/Docker registries, Renovate settings;
  • Links. Submodule URLs, <scm> in pom.xml, links in READMEs and wikis.

The plan:

  1. An inventory: active repos, archived ones, and ones that can be deleted. Usually a third go to the archive.
  2. A pilot: 3-5 repos of different kinds (an ordinary service, a monorepo, one with LFS).
  3. Waves by team: for each repo, a short push freeze, the move, instructions for git remote set-url origin ..., and the old repo set read-only.
  4. Secrets are not moved, they are recreated, and this is a chance to rotate them.

The success criterion is not "the repo moved" but "the team was able to deploy from the new place".