repository to. Add a block like the following to ``git-mirror.conf``::
[repo-name]
- owner = post@ralfj.de
+ owner = email@example.com
local = /home/git/repositories/repo-name.git
deploy-key = ssh-key
mirror-a = git@server2.example.com:repo-name.git
Here, ``local`` has to be set to the path where the repository is stored
locally. ``deploy-key`` is the name of the SSH key used for pushing the changes
-to other repositories. ``owner`` is the e-mail-address that error messages
-occurring during synchronization are sent to. And finally, the URLs to push to
-are given by ``mirror-<something>``. If these other servers also run gitolite
-and have a symmetric setup, then no matter where a change is pushed, git-mirror
-will forward it to all the other repositories.
+to other repositories. ``owner`` is the e-mail-address that errors occurring
+during synchronization are sent to. And finally, the URLs to push to are given
+by ``mirror-<something>``. If these other servers also run gitolite and have a
+symmetric setup, then no matter where a change is pushed, git-mirror will
+forward it to all the other repositories.
Setup (GitHub)
--------------
-This explains how to configure a GitHub repository that should be part of a
-synchronized set. I will assume that one of the copies of the repository lives
-on a gitolite server you control.
+If one of the to-be-synced repositories is on GitHub, you can obviously not use
+the procedure above to sync changes that are arriving at GitHub, to the other
+repositories. Instead, we will use a webhook, such that GitHub tells your server
+that a change happened, and then your server can pull the changes to its local
+repository and synchronize all the others. This assumes that the server running
+the webhook also hosts one of the copies of the git repository.
-Since you cannot install a normal git hook on GitHub, syncing changes that are
-sent to GitHub has to be done with a webhook. First of all, you will have to
-configure your webserver to run ``webhook.py`` as CGI script. Consult the
-webserver documentation for more details.
+First of all, you will have to configure your webserver to run ``webhook.py`` as
+CGI script. Consult the webserver documentation for more details.
Secondly, ``webhook.py`` needs to be able to find the main git-mirror scripts,
and it needs to be able to execute them as the ``git`` user. For the first
The next step is to add this as a webhook to the GitHub repository you want to
sync with, to create a fresh SSH key and configure it as deployment key for the
repository, and to configure git-mirror accordingly. For additional security,
-one shouldalso configure a shared HMAC secret, such that the webhook can verify
+one should also configure a shared HMAC secret, such that the webhook can verify
that the data indeed comes from GitHub.
To make your job easier, there is a script ``github-add-hooks.py`` that can do
all this for you. It assumes that the repository exists on the GitHub side, but
-has not yet been configure for git-mirror, neither locally nor remotely.
+has not yet been configured for git-mirror at all.
To give the script access to your repositories, you need to create an access
token for it. Go to "Personal Access Tokens" in your GitHub configuration, and
Now you can call the automatic setup script as follows::
- ./github-add-hooks.py -o UserName -e email@ddress.com -l ~/repositories/repo-name.git/ -n github-repo-name
+ ./github-add-hooks.py -o UserName -e email@example.com \
+ -l ~/repositories/repo-name.git/ -n github-repo-name
Notice that the username is case-sensitive! This will do all the setup on the
GitHub side, and it will add an appropriate configuration block to your local
-``git-mirror.conf``. You will still have to manually add the local git hook to
-gitolite.
+``git-mirror.conf``. You still have to manually add the local git hook to
+gitolite. Once you are done, any push happening to either gitolite or GitHub
+will be visible on the other side immediately. This applies even to pull
+requests that you merge in the GitHub web interface.
Source, License
---------------