I’m migrating most part of my repositories to the Gitlab.com, because they ultimately have a nice set of features, but I’m not intended to left Github, because it has another nice set of features and also they have a certain charm ;-)

And with that on mind, I was wondering how to sync my repos from Github to Gitlab and also the reverse. I checked some options to do that, but the simplest option that I’ve found was to use an awesome feature available at Gitlab.com, called mirroring repositories.

It is possible to mirror any internet acessible git repository in the both ways (push and pull), so if you update in the Gitlab the other repo is updated as well and also the inverse.

So, I synchronized my github repos with gitlab in that way, follow the steps to configure it, below:

  1. Go to the project page inside Gitlab

  2. In the left sidebar, look for “Settings” option

  3. That option will open a set of other options, click in the “Repository” option

Gitlab screen showing Settings and Repository options

  1. Expand the “Mirroring repositories” option

  2. Fill the “Git repository URL” with the address of your repo, if you use https, you must fill the URL together with the user. Ex.: https://user@github.com/user/repo.git

  3. In the combo “Mirror direction” choose if you will do a Push or a Pull (you can configure both at the same time)

  4. After choose the authentication method, password if you will use https, public key if you will use ssh

  5. If you chose password, you must fill the textbox below with the password of your source repo, if you chose public key you must add a new ssh key.

  6. If you want you can check “Keep divergent refs” or “Only mirror protected branches” (I usually don’t do that)

  7. At last, click in the beautiful green button called “Mirror repository” and that’s it.

Gitlab screen showing the “Git URL repository”, “Mirror direction” and “Authentication method” fields

Detailed view of “Mirror repository” button

So, that’s it for now.