repo is a wrapper around Git to manage multiple repositories.

Python 2 (deprecated):

sudo apt-get install curl ca-certificates git python
mkdir ~/bin/
curl https://storage.googleapis.com/git-repo-downloads/repo-1 > ~/bin/repo
chmod a+x ~/bin/repo

Python 3 (won't work in old build environments):

sudo apt install -y curl ca-certificates git python-is-python3
mkdir ~/bin/
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

Common configuration:

# avoid prompts
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git config --global color.ui true

Some documentation recommend passing repo Git optimizations such as --depth=1 (pruned history) or partial clones (--partial-clone --clone-filter=blob:limit=10M, Git >= 2.19, deferred download). The gain can be significant, unless the target repository was published with "snap"s. This could cause issues with older Git versions (sometimes the build process uses Git to inspect the source status / version), so use with caution.

AFAICS NDK20 uses repo within the build process, but requires an old build environment, so some solution will have to be found if we need to rebuild it after the Python 2 version is removed (rsh to downloader container?).