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
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!
- CSS shape-outside example to wrap text around image - January 7, 2021
- Behind the sun! Pure CSS Animation - January 5, 2021
- Unable to format code in VSCode on MacOS using shortcut (solved) - January 4, 2021