How to mirror Gitlab repo to any other git service

Mirroring git repos from one service to another is very useful in some cases. I wanted to mirror Gitlab repo to Bitbucket repo and it was pretty simple, Here’s how I did it!

Use case of mirroring git repo

There might be different use cases for mirroring but let me explain my use case. I use Gitlab for all my repositories. I was using Gitlab for iWheels repo which is an android app built with React native

I wanted to use App center as CI for deploying my react native app but the problem was that App center doesn’t support integrating Gitlab repo. It supports only GitHub and BitBucket.

So there’s no way to use App center as the CI for my app. So I came up with the idea of mirroring my GitLab repo to BitBucket so whenever I push code to my GitLab repo, it mirrors the commit and pushes the same to BitBucket which in-turn triggers a build in App center!

Pretty cool huh!

How does repository mirroring work

It is pretty simple. You can setup your repo to mirror another repo with a mirror direction. You can either set a push direction or pull direction or both.

If you set push direction then whenever you push code to the first repo then it will be pushed to seconds repo as well

If you set pull direction then if you push the code to the second repo then it will be pulled into first repo

If you set both push and pull directions then it does the both actions as mentioned above.

In most of the cases, Push direction would be more that enough because you would probably be using the 2nd repo as a backup or some CI setup and don’t really make changes to the 2nd repo directly.

How to setup mirroring from Gitlab

Go to your Gitlab repo > Settings > Repository as shown in the image below

gitlab mirror settings
  1. Enter the second repo link in the format https://[email protected]/group/project.git
  2. Select push in mirror direction
  3. Select password in authentication method
  4. Click on Mirror repository

That’s it just few simple steps and your repository mirroring is ready! If you have any questions or feedback then do let me know in the comment section below!

Ranjith kumar
4 3 votes
Article Rating
Notify of

1 Comment
Newest Most Voted
Inline Feedbacks
View all comments
3 years ago

Never know that mirroring repo is so easy