Sync GitLab repo to GitHub?

Hi all! I feel a bit bad to join the forums and immediately drop a help request but I’m a bit lost at the moment…

I installed GitLab in a local server at our office in New Zealand and cloned a GitHub repository so we can all work locally. But I would still like for the GitHub repo to be up to date.

First option I discarded was all devs pulling from the local server but pushing to both repos at the same time because of the international connection to GitHub servers from here is ridiculously slow.

The other idea I had was to have a dedicated system pulling all branches from the local GitLab and pushing to GitHub but I’m wondering if there’s a better way to handle this? Does GitLab have an integrated solution for what I want to do? Or any other ideas I could consider?

Sorry if this sounds obvious… I’ve been reading about this for a couple of hours now and I’m in that information overwhelm state and can’t figure it out so any guidance or reading recommendations will be greatly appreciated!

Hi delebru,

Steps:
A/ These steps init a gitlab repo and fetch sources from github
1/ create a new gitlab
2/ add github as remote

git remote add github git@github.com/[My Organizaton]/[My project].git

3/ fetch to your local repository the github remote
git fetch github master
4/ go to the gitlab master

git checkout master

5/ rebase the gitlab master branch using github

git pull --rebase github master

6/ Sync remote gitlab master

git push origin master

B/ These steps is for syncing gitlab to github
1/ Commit

git checkout -m 'My awesome feature'

2/ Push to remote master (origin/master)

git push origin master

3/ Sync github

git checkout github
git rebase master
git push github master
1 Like

Thanks!! You’re a legend! :slight_smile:

@delebru this fully supported by GitLab, no need for any Git tricks :slight_smile: https://docs.gitlab.com/ee/workflow/repository_mirroring.html#setting-up-a-push-mirror-from-gitlab-to-github

Usually the docs have everything, you can use the dedicated search page https://docs.gitlab.com/search/ to find what you want!

1 Like