The Android Open Source Project (AOSP) is not a single Git repository. It is a massive collection of hundreds of individual Git repositories that must be downloaded, synchronized, and managed together. To handle this immense complexity, Google created the Repo tool.
Why AOSP Uses Repo
If AOSP were a single Git repository, downloading it would be incredibly slow, and branching would be an administrative nightmare. By splitting the project into hundreds of smaller repositories (e.g., one for the kernel, one for the Bluetooth stack, one for the launcher), developers can work on specific components without checking out the entire 250GB OS.
However, running git clone, git pull, and git checkout across 800+ separate repositories manually is impossible. The Repo tool acts as a Python wrapper around Git to automate this exact process.
Essential Repo Commands
1. repo init
This command initializes your local environment and tells Repo which manifest file (the map of all repositories) to use.
- Action: It creates a hidden
.repodirectory in your folder, downloads the manifest repository, and checks out the specific branch. It does not download the actual source code yet.
# Initialize Repo for Android 14
repo init -u https://android.googlesource.com/platform/manifest -b android-14.0.0_r1
2. repo sync
This is the command that actually downloads the source code.
- Action: It reads the manifest file, connects to the remote servers, and performs a
git fetchandgit checkoutfor every single repository listed in the manifest.
# Sync the code using 8 concurrent threads for speed
repo sync -c -j8
3. repo status
When working across multiple repositories, it is easy to forget where you made changes.
- Action:
repo statusscans all 800+ repositories and prints out a list of any files that have been modified, added, or deleted, showing exactly which repository contains the changes.
4. repo forall
This is a powerful command that runs a specific shell command in every single repository simultaneously.
# Instantly wipe away all untracked files and build artifacts across the ENTIRE AOSP tree
repo forall -c 'git clean -fdx'
# Check the current git branch of every repository
repo forall -c 'git rev-parse --abbrev-ref HEAD'
Managing Large Repos Efficiently
Downloading the full AOSP tree can consume over 250GB of disk space. If you only want to browse the code and do not plan to upload changes back to Google, you can perform a "shallow clone".
# Perform a shallow clone, downloading only the latest commit history
repo init -u https://android.googlesource.com/platform/manifest -b android-14.0.0_r1 --depth=1
This downloads only the absolute latest snapshot rather than the entire decade-long git history, saving massive amounts of time and disk space.