Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Migrate from Gitlab to Bitbucket Cloud

Laura Pons October 20, 2020

Hi,

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,

Laura

1 answer

1 accepted

0 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 23, 2020

Hi Laura,

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:

  1. Create an empty repository in Bitbucket Cloud
  2. Take a clone of the Gitlab repo using the --mirror flag in the clone command (this way you have a copy of the entire repository)
  3. Push this mirror clone (from the command line) to the empty Bitbucket Cloud repository you created in the first step

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!

Kind regards,
Theodora

Laura Pons October 26, 2020

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.

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 26, 2020

Hi Laura,

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!

Kind regards,
Theodora

Laura Pons October 27, 2020

ok, perfect. Thanks

Like Theodora Boudale likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events