Gitolite has very advanced mirroring features, but they can be tedious to use if you are just looking to mirror push some repositories to Github (*).
Here is an alternative post-receive hook that doesn't bother with master/slave declarations, and just lets you define one or more target repositories to which to mirror like so:
repo foo-project
RW+ = me
config gitolite.mirror.simple = "git@github.com:miracle2k/foo-project.git"
repo bar-project
RW+ = me
config gitolite.mirror.simple = "git@github.com:miracle2k/bar-project.git git@bitbucket.org:miracle2k/bar-project.git"
It's also possible to mirror multiple repositories in one go:
repo @public-projects
config gitolite.mirror.simple = "git@github.com:miracle2k/REPO.git"
As you can see, REPO will be replaced by the repository name. This is done within the hook.
Finally, you have the ability to add custom options to the mirror push. In this
example, using --no-force
allows you to use the Github web editing features
without fear of accidentally overwriting such changes::
repo @public-projects
config gitolite.mirror.simple = "git@github.com:miracle2k/REPO.git"
config gitolite.mirror.simple.extra-args = "--no-force"
To make the above configurations work, you need to do the following:
-
Edit ~/.gitolite.rc to allow the config keys, for example like so:
GIT_CONFIG_KEYS => "gitolite\.mirror\..*"
-
Setup public SSH authentication from your Gitolite server to the mirror target. Don't forget to connect at least once to pass SSH host key verification.
-
Copy the post-receive hook from this repository to ~/.gitolite/hooks/common, or, preferably, to your own directory that you have setup via LOCAL_CODE. see the Gitolite docs for more. Make sure the file is executable.
-
Run gitolite setup (as the user serving gitolite) once to have the hook installed in all repositories.
To make the above configurations work, you need to do the following:
-
Edit ~/.gitolite.rc to allow the config keys, for example like so:
$GL_GITCONFIG_KEYS = "gitolite\.mirror\..*";
See the Gitolite docs for more on the setting.
-
Setup public SSH authentication from your Gitolite server to the mirror target. Don't forget to connect at least once to pass SSH host key verification.
-
Copy the post-receive hook from this repository to ~/.gitolite/hooks/common, see the Gitolite docs for more. Make sure the file is executable.
-
Run gl-setup (as the user serving gitolite) once to have the hook installed in all repositories.
(*) Or even impossible if the push target does not support the "host:repo" syntax of gitolite; gitolite's mirroring support is primarily intended to mirror between multiple gitolite instances.