Android’s repo
tool simplifies working with hundreds of Git repositories. But syncing the full AOSP (Android Open Source Project) tree, or any large multi-repo setup like your internal Gerrit, can take hours and consume massive bandwidth, especially in CI environments.
To reduce both sync time and network load, you can use a local repo
mirror. This guide shows you how to create a mirror from your own Gerrit instance and leverage it in development or CI workflows.
Why Use a Repo Mirror?
Each repo sync
clones or fetches from dozens (or hundreds) of Git repositories. Without a mirror:
- The same remote Git data is repeatedly downloaded
- Network bottlenecks slow down both local dev and CI
- Cold checkouts or container builds waste time and bandwidth
With a mirror:
- Git object reuse = faster syncs
- Local disk access > network fetches
- CI jobs become much faster and more stable
- Create a Mirror from Gerrit
Choose a server or machine with plenty of available disk space, then run:
mkdir -p ~/mirror
cd ~/mirror
repo init -u git://gerrit.maksonlee.com/platform/manifest \
-b prj-0001-15-vanilla \
--mirror
repo sync -j4
Disk usage warning: A full mirror can easily consume 300–400GB or more, depending on how many repositories and branches are in your manifest. Make sure the machine hosting the mirror has enough storage.
This command fetches all repositories listed in the prj-0001-15-vanilla
manifest branch and creates bare Git mirrors of each one.
The --mirror
flag creates bare repositories, which store all Git data efficiently for reuse.
- Use the Mirror in Clients or CI
On developer machines or CI agents, reference the mirror to avoid re-downloading Git data:
repo init -u git://gerrit.maksonlee.com/platform/manifest \
-b prj-0001-15-vanilla \
--reference=~/mirror
repo sync -j4
--reference=~/mirror
tells Git to reuse objects from your local mirror instead of downloading them again. This significantly reduces bandwidth and speeds up the sync process.
- Keep the Mirror Updated
To keep your mirror synchronized with the latest commits from Gerrit, run:
cd ~/mirror
repo sync -j4
You can automate this with a cron job or systemd timer depending on your environment.