How to synchronize 2 bare repositories in Gitolite

2019-06-01 04:50发布

问题:

I have a following requirement,two remote bare repositories repository A and repository B and my aim is to sync or push repoA contents to repoB @regular intervals.

I use Gitolite v3 btw, should I go for Gitolite mirroring or post-receive hooks? if its a post-receive, how to achieve it?

回答1:

Certainly adding a post-receive hook (see "(v3.6+) variation: repo-specific hooks") is the easiest way.

cd /path/to/your/gitolite-admin-clone
mkdir -p local/hooks/repoA

git push --mirror ../repoB

Mirroring is mainly for synchronization between different gitolite servers (I suppose it could be setup to mirror on the same server as in t/mirror-test, but that it a bit overkill).
Plus it adds:

From v3.5.3 on, gitolite uses an asynchronous push to the slaves, so that the main push returns immediately, without waiting for the slave pushes to complete.
Keep this in mind if you're writing scripts that do a push, and then read one of the slaves immediately -- you will need to add a few seconds of sleep in your script.

That means:

If you have multiple gitolite servers to maintain, then mirroring is interesting, mainly because the push --mirror is done asynchronously from the initial git push to repoA.
In that aspect, gitolite mirroring is quicker, because you push to A, and in the background, gitolite will push --mirror to other gitolite servers.

But here, for just one other repo (on the same gitolite server, or on another gitolite server), a simple post-receive hook is enough.



标签: gitolite