Gerrit跨实例复制无法同步refs/changes问题求助
Let’s work through why your refs/changes aren’t showing up on the target instance, even though branch/tag sync works and logs mention replication activity:
1. Verify Target Instance Permissions for refs/changes
Gerrit locks down access to refs/changes/* by default—even replication users need explicit permissions here. On your target Gerrit instance:
- Go to the
myprojectproject settings - Edit the
projects.configfile (or use the web UI’s Access tab) - Make sure the
gerrit2replication user has the Push permission for therefs/changes/*reference pattern. Without this, the target Gerrit might accept the Git push but won’t index or display the refs in the UI.
2. Explicitly List refs/changes in Replication Rules
While push = +refs... seems like it covers all refs, the 2.12 replication plugin can have ambiguity with broad wildcards for sensitive refs like refs/changes. Update your replication.config to explicitly define these refs:
[remote "hostname"] url = gerrit2@remotehostname.com:/gerrit/review_site/git/myproject.git projects = myproject push = +refs/heads/*:refs/heads/* push = +refs/tags/*:refs/tags/* push = +refs/changes/*:refs/changes/*
This removes any guesswork and ensures the plugin prioritizes syncing change refs.
3. Check if Refs Exist in the Target Git Repository (Beyond Gerrit UI)
Gerrit’s web UI often caches refs, so even if replication worked, you might not see them immediately. On your target server:
- SSH into
remotehostname.com - Navigate to
/gerrit/review_site/git/myproject.git - Run
git show-ref | grep refs/changes
If you see the refs listed here, the replication was successful—just refresh Gerrit’s cache to update the UI:
# On target Gerrit server gerrit flush-caches --all
Restarting the Gerrit service will also force a full reindex of refs.
4. Dig Into Replication Logs for Hidden Errors
Logs might mention refs/changes but hide subtle failures. Check the replication_log on your source Gerrit (usually in review_site/logs/) for lines like failed to push or rejected—these could indicate the target Gerrit is silently rejecting the push due to permission or configuration issues.
5. Account for Gerrit 2.12 Version Limitations
Gerrit 2.12 is an older release, and its replication plugin had known quirks with refs/changes sync. If the above steps don’t resolve the issue:
- Ensure you’re using the latest patch release of the 2.12 replication plugin (check Gerrit’s archive for updates)
- Consider scheduling an upgrade to a newer Gerrit version (e.g., 3.x) where replication logic is more robust—this is a longer-term fix but will prevent similar issues in the future.
内容的提问来源于stack exchange,提问作者Rong Shen

