Using hooks in Gitolite – Push to Github

12 Nov 2015

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:

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

Create ~/.ssh/mirror:

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

Add ~/.ssh/config file

host github
    user git
    identityfile ~/.ssh/mirror

host bitbucket
    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 option:

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