In this brief post I’ll describe how to mirror a gitlab repository to another gitlab instance. And how to mirror it to github. This way you’ll only have to push once and it’ll appear in multiple locations. The same thing should be possible from github, that is however not described here.

Gitlab: At the destination gitlab instance (the one you want to mirror to), you’ll need to head over to Settings -> Access Tokens. Over here we’ll have to create a personal access token, name it something like “Gitlab mirror …” and give it the write_repository scope. Afterwards head over to the gitlab you want to mirror from and navigate to the repository that you want to mirror. Over here navigate to Settings -> Repository -> Mirroring repositories. Now copy the https link of the repository of the destination into the “Git repository URL” field. And add oauth2:@ just after the https:// bit, so it should look like https://oauth2:@gitlab.com/.... Keep the mirror direction set to push and authentication method to password. Now simply fill the the previously created personal token in the password field and add the mirror. That’s it, it’ll now mirror to the destination gitlab on every push.

Github: The trick for github works mostly the same as gitlab, except for some small details. To start off we’ll need to create a personal access token, we do this by going to Settings -> Developer Settings -> Personal access tokens. Over here we once again need to create a personal token, this time we need to give it the repo scope (in case of a public repository the repo -> public_repo scope is enough). Give your token a useful not like “Gitlab mirror …” again so you can later on remember what it was for. Now we head over to the gitlab repository and navigate to Settings -> Repository -> Mirroring repositories. Copy the https link of the github repository into the “Git repository URL” field. Now add your username just after the https:// part of the url, make sure to put a :@ after it. Your link should look something like this https://schoentoon:@github.com/.... Now simply paste your previously created personal token in the password field and add the mirror. That’s it and gitlab will now mirror to github on every push.