Using hooks in Gitolite – Push to Github

Mirror in Gitolite is a bit too complicated to setup. What I am seeking for is to automatically push to github while I push to my gitolite repository.

On the server

Change ~/.gitolite.rc file:

80c80
<         # LOCAL_CODE                =>  "$rc{GL_ADMIN_BASE}/local",
---
>         LOCAL_CODE                =>  "$rc{GL_ADMIN_BASE}/local",
164c164
<             # 'repo-specific-hooks',
---
>             'repo-specific-hooks',

Create ~/.ssh/mirror:

ssh-keygen -t rsa -N “” -f ~/.ssh/mirror

Add ~/.ssh/config file

host github
    hostname github.com
    user git
    identityfile ~/.ssh/mirror

host bitbucket
    hostname bitbucket.org
    user git
    identityfile ~/.ssh/mirror

In gitolite-admin.git

Add hook file local/hooks/repo-specific/mirror:

git push --mirror github:username/$GL_REPO.git
git push --mirror bitbucket:username/$GL_REPO.git

In repo config, add hook.post-update option:

repo testing
    RW+     =   @all
    config gitweb.description = For testing purpose.
    config gitweb.owner = Jian Zhou
    option hook.post-update = mirror