heya!
quick bit of blogumentation on switching source control systems. I'm moving us over from GitLab to GitHub at work, and I'd like to document my approach just in case I need to do this in future.
this approach seems like it's the simplest I've come across, and copies over all the branches. however,
- I'm not sure if it copies tags, but we don't use those anyway. it likely does, but I can't say for sure
- this doesn't preserve merge request history, either. we had a discussion on the engineering proposal I raised, and that's context we're fine with losing
method
- clone bare repository from old source control
git clone --mirror [old_origin] - create new repository in new source control
- in the repository directory, switch origin of bare repository
git remote set-url origin [new_origin] - in the repository directory, push bare repository
git push --mirror
why does this work?
well, a bare repository just a repository's .git folder. that means you're simply cloning all the data git tracks in its most raw form, and then pushing it somewhere else.
I chose to clone bare because
- it's different enough from my day-to-day repos that I don't get confused,
- there's no way to make a change to the working tree and push that to new source control by accident.
I thought it would be more space efficient, given there's no working tree. however, that doesn't seem to be the case. I can't give details for repositories at work, but I played around with the makeplane/plane repo to check my hypothesis.
~/Documents/projects
❯ git clone [email protected]:makeplane/plane.git
Cloning into 'plane'...
remote: Enumerating objects: 199172, done.
remote: Counting objects: 100% (1969/1969), done.
remote: Compressing objects: 100% (790/790), done.
remote: Total 199172 (delta 1567), reused 1179 (delta 1179), pack-reused 197203 (from 3)
Receiving objects: 100% (199172/199172), 141.45 MiB | 8.45 MiB/s, done.
Resolving deltas: 100% (145474/145474), done.
~/Documents/projects
❯ git clone --mirror [email protected]:makeplane/plane.git
Cloning into bare repository 'plane.git'...
remote: Enumerating objects: 346488, done.
remote: Counting objects: 100% (1508/1508), done.
remote: Compressing objects: 100% (596/596), done.
remote: Total 346488 (delta 1186), reused 919 (delta 892), pack-reused 344980 (from 4)
Receiving objects: 100% (346488/346488), 185.88 MiB | 6.73 MiB/s, done.
Resolving deltas: 100% (258886/258886), done.
~/Documents/projects
❯ du -hs plane plane.git
199M plane
202M plane.gitcloning makeplane/plane with and without --mirror, and comparing directory sizes
slightly larger. interesting.