I’m running a gitolite instance on my personal server to manage my repositories (personnal, private or public) ; and I am quickly going to share with you how I setup a quick and dirty mirror feature.
First, I am using gitolite 3. The mirroring we are going to setup is not the supported mirroring built-in. We are going to implement a simplier way to set mirror thing :
- Write a custom gitolite command ; the idea is to be able to write
- Write a hook that take a specific
mirror.url) and do a simple mirroring.
Gitolite 3 has been rewritten to be more flexible : Why a completely new version.
The rewrite made it really easy to extend gitolite.
I’ve fork gitolite on github
I’ve created a repository git
to easily add commands to my gitolite instance via local code. The gitolite command I wrote is
a quick and dirty script in shell to add
git config. The source should speek
for itself ; It should include some way to check if the given config is not
already present in the
gitolite-admin configuration file — and so might be
The command is
write-git-config because a
git-config command already exists
in the built-in commands.
The next step is to write a quick
post-receive hook that check if there is a
git-config entry and run
git push --mirror. The file is in
$HOME/.gitolite/hooks/common/post-receive ; you could add a better system to
hooks (to be able to add “dynamic” hooks, …).
The next, and final step is to run
gitolite compile to update links to hooks
for every repositories.
And finaly, this is the final step you’ll do.
$ ssh git@host write-git-config vincent/vcsh-home mirror.url email@example.com:vdemeester/vcsh-home.git $ git push Counting objects: 5, done. Delta compression using up to 2 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 294 bytes, done. Total 3 (delta 2), reused 0 (delta 0) remote: To firstname.lastname@example.org:vdemeester/vcsh-home.git remote: 65681a8..701c990 master -> master To git@host:vincent/vcsh-home.git 65681a8..701c990 master -> master
And that should be it !
Update 2012/10/04 : Moved from gitolite fork to gitolite local code repository.