Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I mirror and synchronize GitHub and SourceForge repositories?

I have a repository on GitHub and an empty repository at SourceForge. How do I make mirrors and synchronize them?

On StackOverflow there is "Mirroring a repository across Github, Sourceforge and Google Code" which explains how to push to multiple repositories, but how do I synchronize them when commits will be in GitHub or SourceForge?

like image 565
Borneq Avatar asked Sep 29 '13 17:09

Borneq


2 Answers

Keep two separate remote one for google code and another for github.

git remote add origin <<your google code repo url>>
git remote add github <<your github repo url>>

Now you have two ways to sync the repos.

git remote update

This will fetch from all remote urls but won't merge. You have to merge the code manually. Alternatively if you need all the commits in both of your mirrors you can pull from them separately by specifying a branch name to which the the code to be merged (possibly master).

git pull origin master
git pull github master

pushing to multiple branches can be done as mentioned in the link in your question or using individual commands

git push origin master
git push github master
like image 111
gnuanu Avatar answered Oct 22 '22 10:10

gnuanu


I'm afraid neither Github nor Source Forge offers mirroring functionality.

At first glance I can see two options but both would require a third server (local or in any cloud provider). I'm gonna call it sync server.

One option would be to setup your sync server to pull from the source and push to the mirror. You could use a simple crontab for that. If you allow writes on both ends you might have a problem with this approach.

A second and more complicated option would be to create and setup webhooks (which both github and SF support) on your sync server. Every time you get a push the webhook will be called and you will be allowed to perform the exact same push to the order git server. This approach is a bit safer but still could fail in case two different pushes happen at same time in both servers. That's a classical problem in master-master distributed system.

like image 26
Sergio Oliveira Avatar answered Oct 22 '22 10:10

Sergio Oliveira