How to automatically mirror a Gitlab project to Github

To add the post-receive hook, you must follow the steps......

Sometimes you need to auto-sync Gitlab repos to Github, so here's what you have to do.

We need to add a post-receive hook in Gitlab's repo, on the Gitlab's server, which will trigger every time you do a push to the Gitlab's repo.

To add the post-receive hook, you must follow the steps:

A. On the Gitlab server:

su git
cat ~/.ssh/

Add this pub key to Github, in here:, with write access.

B. On the Gitlab server, you should now be able to:

ssh -T

C. On the Gitlab server:

cd ~/git-data/repositories/Organization/RepoName.git
git remote add github
mkdir custom_hooks
cd custom_hooks
nano post-receive

add the following in the post-receive file:

#!/usr/bin/env bash
git push --mirror github

then write to file, exit, and:

chmod +x post-receive

That's about everything, let us know if you have questions.

Want more awesome stuff?

Check us out on our Medium Remote Symfony Team publication.