Repo (Git Tool) Commands
Repo (Git Tool) Commands
Repo complements Git by simplifying work across multiple repositories. See Source Control
Tools (/docs/setup/develop) for an explanation of the relationship between Repo and Git. For
more details on Repo, see the Repo README
(https://gerrit.googlesource.com/git-repo/+/HEAD/README.md).
Optional elements are shown in brackets [ ]. For example, many commands take project-list
as an argument. You can specify project-list as a list of names or a list of paths to local
source directories for the projects:
help
This page merely highlights key options. See the command line help for full details. When
Repo is installed, you can find the latest documentation starting with a summary of all
commands by running:
$ repo help
You can see detailed information about any command by running this within a Repo tree:
For example:
init
Installs Repo in the current directory. This creates a .repo/ directory with Git repositories
for the Repo source code and the standard Android manifest files.
Options:
-u : Specify a URL from which to retrieve a manifest repository. The common manifest
is found at https://android.googlesource.com/platform/manifest .
-m : Select a manifest file within the repository. If no manifest name is selected, the
default is default.xml .
sync
Downloads new changes and updates the working files in your local environment,
essentially accomplishing git fetch across all Git repositories. If you run repo sync
without arguments, it synchronizes the files for all projects.
If the project has never been synchronized, then repo sync is equivalent to git
clone . All branches in the remote repository are copied to the local project directory.
If the project has been synchronized before, then repo sync is equivalent to:
where branch is the currently checked-out branch in the local project directory. If the
local branch isn't tracking a branch in the remote repository, then no synchronization
occurs for the project.
If the Git rebase operation results in merge conflicts, use the normal Git commands
(for example, git rebase --continue ) to resolve the conflicts.
After a successful run of repo sync , the code in specified projects is up to date and
synced with the code in the remote repository.
Here are key options. See repo help sync for more:
-jthreadcount : Split the sync across threads for faster completion. Ensure you don't
overwhelm your machine - leave some CPU reserved for other tasks. To see the
number of available CPUs, first run: nproc --all
upload
For the specified projects, Repo compares the local branches to the remote branches
updated during the last Repo sync. Repo prompts you to select one or more of the branches
that haven't been uploaded for review.
All commits on the selected branches are then transmitted to Gerrit over an HTTPS
connection. You need to configure an HTTPS password to enable upload authorization.
Visit the Password Generator (https://android-review.googlesource.com/new-password) to
generate a new username/password pair to use over HTTPS.
When Gerrit receives the object data over its server, it turns each commit into a change so
that reviewers can comment on a specific commit. To combine several checkpoint commits
into a single commit, use git rebase -i before you run the upload.
If you run repo upload without arguments, it searches all of the projects for changes to
upload.
To edit changes after they've been uploaded, use a tool like git rebase -i or git commit
--amend to update your local commits. After your edits are complete:
Verify that the updated branch is the currently checked out branch.
Use repo upload --replace PROJECT to open the change matching editor.
For each commit in the series, enter the Gerrit change ID inside the brackets:
After the upload is complete, the changes have an additional patch set.
If you want to upload only the currently checked out Git branch, use the flag --current-
branch (or --cbr for short).
diff
Shows outstanding changes between the commit and the working tree using git diff .
download
Downloads the specified change from the review system and makes it available in your
project's local working directory.
Running repo sync removes any commits retrieved with repo download . Or you can
check out the remote branch using git checkout m/main .
Note: There are replication delays to all servers worldwide, so there's a slight mirroring lag between when
a change is visible on the web in Gerrit (https://android-review.googlesource.com/) and when repo
download can find the change for all users.
forall
Executes the given shell command in each project. The following additional environment
variables are made available by repo forall :
REPO_LREV is the name of the revision from the manifest, translated to a local
tracking branch. Use this if you need to pass the manifest revision to a locally
executed Git command.
REPO_RREV is the name of the revision from the manifest, exactly as written in the
manifest.
Options:
prune
start
$ repo start
branch-name edit [project-list edit]
Begins a new branch for development, starting from the revision specified in the manifest.
The project-list argument specifies which projects participate in this topic branch.
Note: A period ( . ) is shorthand for the project in the current working directory.
status
$ repo status [project-list edit]
Compares the working tree to the staging area (index) and the most recent commit on this
branch (HEAD) in each project specified. Displays a summary line for each file where there
is a difference between these three states.
To see the status of just the current branch, run repo status . . The status information is
listed by project. For each file in the project, a two-letter code is used.
In the first column, an uppercase letter indicates how the staging area differs from the last
committed state.
In the second column, a lowercase letter indicates how the working directory differs from
the index.
Letter Meaning Description
repo: error: no branches ready for upload appears when the command
The error
repo start wasn't run at the start of the session. To recover, you can check the commit id,
start a new branch and then merge it.
Content and code samples on this page are subject to the licenses described in the Content License (/license).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.