Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically mirroring a GitHub repo

Tags:

git

github

mirror

I suspect this question has been asked before, though all I can find are similar but distinct questions or the same one with only solutions that do not work for me.

There is a repository on GitHub that I have no control over and would like to mirror. With mirror I mean have a clone that gets updated automatically. I want this mirror to also be on GitHub. Preferably any solution would not involve much configuration or setup work from my side. However if needed I can have a script run using a cron on some VPS.

Can I create such a mirror purely via GitHub? If not, are there ready to use scripts to do this?

like image 645
Jeroen De Dauw Avatar asked Apr 08 '13 05:04

Jeroen De Dauw


People also ask

What is git remote mirroring?

Git mirroring is when a mirror copies the refs & the remote-tracking branches. It's supposed to be a functionally identical copy that is interchangeable with the original.

What does mirror mean in GitHub?

Repository Mirroring is a way to mirror repositories from external sources. It can be used to mirror all branches, tags, and commits that you have in your repository.

How do I clone a git repository to another repository?

You first have to get the original Git repository on your machine. Then, go into the repository. Finally, use the --mirror flag to copy everything in your local Git repository into the new repo.


1 Answers

Interesting question, considering all Eclipse repos are mirrored on GitHub.

But, as illustrated by the recent (April 2013) article from Wayne, the re is no automatic GitHub way to mirror a repo.

As far as I know, GitHub provides no mechanism to schedule a regular pull (correct me if I’m wrong), which means that it would become our responsibility to push to the GitHub clone.

See also bug 402183.

So a script on a VPS (ie, something you setup) remains the surest way to implement this.

Building on "HowTo mirror your git repository on Github", you would need your own local clone, with a script which would:

  • regularly pull from the GitHub repo
  • push to the mirror on Github

Update 2015 (2 years later): a tool like beefsack/git-mirror (in go) is:

designed to create and serve read-only mirrors of your Git repositories locally or wherever you choose.
A recent GitHub outage reinforces the fact that developers shouldn't be relying on a single remote for hosting code.

like image 120
VonC Avatar answered Oct 25 '22 06:10

VonC