Use GitHub as a mirror for your GitLab projects
Aug 20, 2016
1 minute read

As GitHub is more popular than GitLab, I wanted some of my personal projects also get hosted on GitHub. Here is a three step manual to mirror a GitLab Repository.

1. Create Repository and SSH key

First create a new repository where the mirror is getting to be stored. I have a project named JPAL on Gitlab (https://gitlab.com/arturbosch/JPAL) so i created a GitHub repository with the same name (https://github.com/arturbosch/JPAL).

Fetch your ssh key with cat ~/.ssh/id_rsa.pub and save it in GitHub under Settings -> SSH … -> New SSH key.

2. Edit config

Add following host data in your .git/config (replace with your repository).

[remote "github"]
  url = git@github.com:arturbosch/JPAL.git
  fetch = +refs/*:refs/*
  mirror = true

3. PUSH

Finally you can push to your mirror:

git push --mirror github

PS: Somehow you can write a push hook which updates your mirror automatically. If I find out how, I will post it here!