To mirror a GitHub repo onto Gitolite, first create a new repo on Gitolite (using the gitolite-admin
repo - I'll assume the Gitolite admin knows how to do that), but here's an example config entry:
repo github/<gh-user>/<gh-repo>
desc = "Repository description [https://github.com/<gh-user>/<gh-repo>]"
owner = "My Name"
category = "GitHub"
RW+ = my_key
where <gh-user>
is the GitHub user and <gh-repo>
is the GitHub repository being mirrored. This example places the mirror within a GitHub and user subdirectory, but you can use any repo
path that suits.
Then, from anywhere with access to both GitHub and Gitolite:
$ git clone --mirror https://github.com/<gh-user>/<gh-repo>
$ cd <gh-repo>.git
$ git push --mirror gitolite git@git:github/<gh-user>/<gh-repo>
$ cd ..
$ rm -rf <gh-repo>.git
where git@git
is the SSH user and hostname used to connect to Gitolite. The local clone is temporary and is deleted afterwards.
The OP asked only about moving repositories, in which case he might stop here. However, should it be desirable to host a local mirror of a repo on GitHub and periodically synchronize the local mirror then here's a way to do that.
To sync the Gitolite mirror with GitHub, log on to the Gitolite server as the Gitolite admin (git
) user and perfom the following configuration:
$ cd ~git/repositories/github/<gh-user>/<gh-repo>
$ git remote add origin https://github.com/<gh-user>/<gh-repo>
$ git config remote.origin.fetch "+*:*"
The parameters in the commands are explained clearly here.
Then, to sync the repo:
$ git fetch --prune
The fetch could be automated via a cron
job.