Migrate repos between instances of Gitlab
I recently migrated from gitolite to gitlab and the official rake task gitlab:import:repos
worked for me. I am using gitlab 6.1.0 (82f3446). Here is what I did:
rsync
bare repos from gitolite torepositories/{group}/
. Make sure to replace{repository}
with the name of the gitolite repo, and change the hostname of your gitlab server.rsync -rth --progress repositories/{repository}.git \ git@gitlab-server:/home/git/repositories/{group}/
Here,
{group}
is the name of the user group you want the repository to be added to. If you don't have any specific group, chooseroot
as the group name.Fix permissions – only necessary when the
rsync
user is notgit
:sudo chown -R git:git repositories/{group}/
cd ~/gitlab
Run the rake task to import all new repositories:
bundle exec rake gitlab:import:repos RAILS_ENV=production
Now if you login as Administrator you will find the new project added.
For more information, refer to the "Import bare repositories into GitLab project instance" under http://{your-gitlab-server}/help/raketasks
.
In your case, you can login to your old TKL system and rsync all bare repos to the new instance, followed by an import.
One option would be to:
- Clone the old repo from gitlab onto a dev machine.
- Create a blank repo on the new gitlab.
- Add the new repo as a remote on the dev machine.
- Push everything back to the new repo.
- Remove the old repo from remote repos list.
To create a remote called newRepo, do: git remote add newRepo gitlab.localhost.com:User/newRepo.git
(replace the url on the end with the one for your repo)
I did it practically the following way after reading ChrisA answer, which gave me a little headache about how to do it practically. The example copies a repo from github to gitlab, to make source and destination a little bit clearer.
Clone the old repo from github onto a dev machine (which creates a bare repo):
$ git clone --mirror [email protected]:me/myrepo.git
Create a blank repo on the new gitlab.
Add the new repo as a remote on the dev machine.
$ cd myrepo.git $ git remote add newRepo [email protected]:me/myrepo.git
Push everything back to the new repo.
$ git push --mirror newRepo
That's it.
This way it copied all branches and tags to the new destination.
You can now remove the cloned bare repo from your dev machine.