Skip to content

Instantly share code, notes, and snippets.

@slok
Created December 8, 2011 11:30
Show Gist options
  • Save slok/1446768 to your computer and use it in GitHub Desktop.
Save slok/1446768 to your computer and use it in GitHub Desktop.
Create github and bitbucket mirror in gitolite

Create Github/Bitbucket Mirror

Create SSH key and configure

Create Key (no passphrase and name mirror the key)

ssh-keygen -t rsa -N "" -f ~/.ssh/mirror

Create a file in ~/.ssh/config (or edit) with this data (for github/bitbucket)

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

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

Add RSA server keys to known hosts

ssh github
ssh bitbucket

Create Git repo hook

Create the hook(post-receive) in the repo (for example mirror-test.git bare repo)

cd /home/git/repositories
mv ./mirror-test.git/hooks/post-receive.sample ./mirror-test.git/hooks/post-receive

Edit this recent created hook (we are going to use github and bitbucket with the ssh key and config created previously)

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

We are using gitolite $GL_REPO variable

Dont forget to add the mirror.pub key to github/bitbucket! and create the repository

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment