Is two way sync between gerrit and possible?

For a project exisitng in private repository, I am setting up gerrit code review.

I am using the gerrit's replication plugin to keep the gerrit repository in sync with

But if someone commits (say commit-a) and pushes directly to, the commit-a is overwritten in, when gerrit does the replication process (because, it replicates only the things in gerrit mirror).

But I want to implement a 2-way sync. Something like, whenever a push is made to gerrit, it has to check and update its mirror with new code from there and then to continue the merge.

Is that possible?


This is a hard problem. Multi-master setups like what you describe exist in many places, but rely on the involved systems to be heavily integrated and built to support this.

I see two options:

  • Both Gerrit and Github would have to be capable of talking to each other and allow the git on server A to be locked while server B updates its ref. Once B has been updated, the data is replicated to A, and A is unlocked. This feature does not exist and probably never will.
  • The server receiving a push could be optimistic and hope that a concurrent update won't happen. For a moderately busy server this won't happen most of the time, but if it does happen there must be a sane recovery strategy. Recovery becomes much more difficult if not impossible if the concurrency check is done asynchronously, i.e. if e.g. Gerrit signals "okay" on the push before actually securing the transaction with Github first. Synchronous updates would solve this but would be detrimental to performance and reliability.

It might not be the direct answer to your question, but if you would make Gerrit your source of truth and you only care about pull requests, you can use the github plugin to import the PR into a Gerrit change.

This wouldn't help, of course, if anybody pushes commits directly to Github.

In general, I agree with Magnus B├Ąck.

Need Your Help

How to search single keyword from multiple file in perl?

perl file arguments keyword perl-module

I have two to three files. In this files path of directories are given. In these file another files are also given. The keyword is given by argument. And these file's name are also given as argumen...