How do we migrate repositories from Gitlab (hosted in house) to Bitbucket Cloud? When I try to import a repository, because we are using a local IP, the URL is not valid.
If so, then I am wondering it:
- There is any chance we can migrate a large amount of repositories (about 150) from GitLab to Bitbucket Cloud via command line or using a tool / plugin?
- Convert gitlab groups into bitbucket projects automatically? Our repositories are grouped in Groups in GitLab, but groups are not supported in Bitbucket.
Thanks in advance,
I'm not aware of any such tools for an automated migration.
In order to use the Import functionality, the Gitlab instance should be accessible from the internet.
Another way to migrate would be the following:
It may be possible to create a script to automate this process so you won't have to do this manually for every single repo: retrieve a list of all Gitlab repos via Gitlab API (if possible), and for each one of them, take a mirror clone of the repo, create an empty repository in Bitbucket Cloud (via API https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D#post) and then push to the newly created Bitbucket repo.
Regarding migrating Gitlab groups to Bitbucket projects, I don't believe that there is a tool for that either. If the info about Gitlab projects can be retrieved via their API, it may again be possible to automate this process with a script using API of both products (API for Bitbucket projects can be found here: https://developer.atlassian.com/bitbucket/api/2/reference/resource/workspaces/%7Bworkspace%7D/projects#post).
Please feel free to let me know if you have any questions!
Hello Theodora, thanks for your reply! That's exactly what I did. I exported all gitlab repositories as a json file with all information, and took the group names to create new projects if they didn't exist in bitbucket cloud already, and migrated the repositories using name, repo_slug, description, is_private,... from the json file. The only thing I slightly modified was to use --all and --tags instead of --mirror:
git push --all $repo_slug
git push --tags $repo_slug
Would you rather use --mirror instead of --all/--tags?
Thanks for helping on this.
You're very welcome, happy to help!
If you don't have a mirror clone, you can use git push --all and git push --tags. In this case, the local clone you are pushing from should have all the remote branches. In case a repo has e.g. 50 branches and you have locally only 2 or 3 of them, you'd need to fetch and pull all the rest, in order to push an exact copy of the repo to Bitbucket. This can be time consuming if the repo has a large number of branches. In this case, a mirror clone may be easier, as you don't need to worry about pulling all branches first.
If your repos have only a couple of branches, and all of them have been pulled in the local clone you are going to push from, then I don't see an issue using git push --all and git push --tags.
Feel free to let me know if you need anything further!
Announced in this blog, this holiday season we’re celebrating all things CI/CD and between now and the end of 2019 we’ll be showcasing content, use cases, feature announcements and more. One featur...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events