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

Is it possible to mirror a Bit bucket repository to GITLAB??

Srikanth Vemuluri February 27, 2023

Hello All,

We need to mirror one Bit bucket repository to GitLab. Is it possible to do this??
If so please let us know the process to do it in Bit bucket cloud version. 

1 answer

1 accepted

1 vote
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 1, 2023

Hi @Srikanth Vemuluri,

If you have a Premium subscription with GitLab, I see in their documentation that they offer a pull mirroring functionality from repositories that aren't hosted in GitLab:

If you don't have a Premium GitLab subscription, there are other ways to set this up:

If you make a clone of the Bitbucket Cloud repo on your machine with the --mirror option, you have a copy of the repo with all branches:

git clone --mirror <bitbucket_repo_url>

You can then navigate to the directory of the mirror clone and push to an empty GitLab repo:

git push --mirror <gitlab_repo_url>

In order to update the mirrored repository in GitLab, you can run the following commands in the directory of the mirror clone

git fetch -p origin
git push --mirror <gitlab_repo_url>

You could write a script that performs these operations (fetch and push) and schedule it to run periodically.

Another option is to use Bitbucket Pipelines to automate this process and run a pipelines build every time there is a push to the repo. You could use a bitbucket-pipelines.yml file similar to that one:

image: atlassian/default-image:4

- step:
enabled: false
name: 'Mirror repository'
- git clone --mirror ${BITBUCKET_GIT_SSH_ORIGIN}
- git push --mirror <gitlab_repo_url>

Such a pipeline will run on every push to the repo, but you can also use a custom pipeline and schedule it to run at certain times/days.

You will need to set up authentication details to push to the GitLab repo. If you want to use SSH keys, you can set up SSH keys in Pipelines, and upload the public key to a GitLab account that has write access to that GitLab repo:

You could also check what other authentication methods GitLab provides, e.g. tokens, and use HTTPS Basic Authentication with a token, instead of SSH.

If you have any questions, please feel free to reach out.

Kind regards,

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events