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
- Enter the second repo link in the format
- Select push in mirror direction
- Select password in authentication method
- 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!
- Curved button using Flutter | Can it be done with Flutter? | Custom shapes Flutter | Custom painter - September 21, 2022
- Dynamic Island using Flutter | iPhone 14 Pro | Can it be done with Flutter? - September 14, 2022
- Best practices of scraping website data for beginners (Updated 2022) - September 12, 2022
Never know that mirroring repo is so easy