DEV Community

Dmitry Kabanov
Dmitry Kabanov

Posted on

12 1 1

How to mirror GitLab repo to GitHub

If you have a GitLab repo and would like to mirror it in your GitHub account, it can be set up directly in the GitLab repo settings. Note that here we use new fine-grained tokens functionality of GitHub (which is currently in beta, as of May 2023).

Go to the project's settings (Settings -> Repository) and expand "Mirror repository". You will see the following form:
Mirror repository form on GitLab

In the "Git repository URL", you need to specify the HTTPS URL for the repo on GitHub in the following format:
https://github-username@github.com/github-username/repo.git
Note the added username part between // and @ in the above URL --- when you create a repository on GitHub, the generated URLs do not have this, so you need to add it manually!

Now, for a password, we use fine-grained tokens. Press "Generate new token" button and choose read and write permissions for "Contents".

Copy the generated token and paste it into the "Password" field in GitLab. Finally press "Mirror repository" button. Once you see a table with mirrors appeared, you can press "Update now" (two arrows) button to check if everything works correctly.

Right now, usability is a bit off, as if something is not working, you have to delete the mirror and start over again. It would be a better user experience, if GitLab allowed to edit the mirror settings.

Hopefully, these instructions work good for you. Enjoy!

P.S. This two StackOverflow posts were really helpful to write the above instructions:

Image of Datadog

Master Mobile Monitoring for iOS Apps

Monitor your app’s health with real-time insights into crash-free rates, start times, and more. Optimize performance and prevent user churn by addressing critical issues like app hangs, and ANRs. Learn how to keep your iOS app running smoothly across all devices by downloading this eBook.

Get The eBook

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more