Question

How do I create a github mirror for an external git repository, such that it appears as "real mirror", e.g., as in https://github.com/mirrors?

So far, I set up a mirror using:

cd /path/to/bare/repository
git remote add --mirror github git@github.com:user/repo.git

and configure the post receive hook to do a git push --quiet github. This way, however, github does not recognize the mirror.

Any ideas how to do it the github way, such that "Mirrorred from" appears underneath the repostiory name?

Was it helpful?

Solution

Based on communicating with GitHub's support team, I found that GitHub currently offers no direct mechanism for a user to mirror repositories in this fashion.

However, one can ask GitHub to install this service for repositories which are part of an organization. GitHub then configures an existing repository as such a mirror and pulls from it in an interval that is a function of the number of overall mirrors they have.

EDIT: as Stuart points out, GitHub no longer accepts requests for mirroring arbitrary repositories. The only remaining option is the solution I posted in my question, i.e., creating a post-receive hook to automatically push to your GitHub repository.

OTHER TIPS

Judging by the current content of https://github.com/mirrors, it would appear GitHub no longer does "official mirrors", as most projects that want their code mirrored on GitHub today just makea an organization for it, such as Git itself.

There is also a feature request at: https://github.com/isaacs/github/issues/415

According to Importing a Git:

For purposes of demonstration, we'll use:

  • An external account named extuser
  • A GitHub personal user account named ghuser
  • A GitHub repository named repo.git

The command line:

# Makes a bare clone of the external repository in a local directory  
$ git clone --bare https://githost.org/extuser/repo.git

# Pushes the mirror to the new GitHub repository
$ cd *repo.git*
$ git push --mirror https://github.com/ghuser/repo.git

# Remove the temporary local repository.
$ cd ..
$ rm -rf repo.git

I have used a tool called github-backup with moderate success to, if not mirror, at least make a full backup (including issues and other metadata) of a Github user or organization. To quote the README file:

Each time you run github-backup, it will find any new forks on GitHub. It will add remotes to your repository for the forks, using names like github_torvalds_subsurface. It will fetch from every fork.

It downloads metadata from each fork. This is stored into a branch named "github". Each fork gets a directory in there, like torvalds_subsurface. Inside the directory there will be some files, like torvalds_subsurface/watchers. There may be further directories, like for comments: torvalds_subsurface/comments/1.

You can follow the commits to the github branch to see what information changed on GitHub over time.

The format of the files in the github branch is currently Haskell serialized data types. This is plain text, and readable, if you squint.

Limitations include:

  • no private repository support
  • no "social" stuff like stars, followers, etc
  • notes to lines of commits are not supported (yet?)
  • issue labels
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top