Repo command reference
转载:
AOSP > Documentation > Getting Started > Repo Command Reference
Repo complements Git by simplifying the process of running across multiple code bases. Source code control tools
1、help
repo help
repo help [command]
2、init
repo init -u url [options]
Install Repo in the current directory. This creates a .repo/
directory that contains the Git repository that houses the Repo source code and the standard Android manifest files.
Options:
- -u: Specifies the URL from which to retrieve the manifest repository. Common manifests are at https://android.googlesource.com/platform/manifest.
- -m: Select the manifest file in the code base. If no manifest name is selected, it defaults to default.xml.
- -b: Specify the revision, that is, a specific manifest-branch.
3、sync
repo sync [project-list]
Downloading new changes and updating working files in your local environment can be done in basically any Git repository git fetch
. If run without any arguments repo sync
, the command synchronizes files for all projects.
After running
repo sync
, the following will occur:
- If the target project has never been synchronized, repo sync is equivalent to git clone. All branches in the remote repository are copied to the local project directory.
- If the target project has been synced before, repo sync is equivalent to:
git remote update git rebase origin/branch
Where branch is the currently checked-out branch in the local project directory. If the local branch is not tracking the branch in the remote repository, no synchronization will occur for the project.
- If a Git rebase operation causes merge conflicts, use regular Git commands (such as git rebase --continue) to resolve the conflicts.
After running repo sync successfully, the code in the specified project is up to date and synchronized with the code in the remote repository.
Below are the important options. To learn more, see
repo help sync
:
- -c: Get only the current manifest branch in the server.
- -d: Switch the specified project back to the manifest revision. This option is helpful if the project currently belongs to a topic branch but temporarily requires a manifest revision.
- -f: Even if the synchronization of a certain project fails, continue to synchronize other projects.
- -j
threadcount
: Split synchronization operations into multiple threads to complete faster. Make sure you don't overload your computer - reserve some CPU for other tasks. To see the number of available CPUs, first run:nproc --all
- -q: Ensure that the running process is uninterrupted by suppressing status messages.
- -s:
manifest-server
Synchronize to a known good build specified by the element in the current manifest .
4、upload
repo upload [project-list]
For the specified project, Repo compares the local branch with the remote branch that was updated during the last Repo sync. Repo will prompt you to select one or more branches that have not yet been uploaded for review.
Next, all commits on the selected branch are transferred to via HTTPS connection Gerrit
. You need to configure an HTTPS password to enable upload authorization. To generate a new username/password pair for HTTPS transfer.
When Gerrit receives object data through its server, it turns each commit into a change so that reviewers can comment on that specific commit. To combine several "checkpoint" commits into one, run git rebase -i
and then run upload
.
If run without any parameters repo upload
, the command searches all projects for changes to upload.
To modify your changes after they've been uploaded, update your local submission using tools like git rebase -i
or . git commit --amend
After the modification is completed, please perform the following operations:
- Verify to ensure that the updated branch is the currently checked-out branch.
- Use to
repo upload --replace PROJECT
open the change match editor. - For each commit in the corresponding series, enter the Gerrit change ID within square brackets:
# Replacing from branch foo
[ 3021 ] 35f2596c Refactor part of GetUploadableBranches to lookup one specific...
[ 2829 ] ec18b4ba Update proto client to support patch set replacments
# Insert change numbers in the brackets to add a new patch set.
# To create a new change record, leave the brackets empty.
Once uploaded, these changes will have an additional patch set.
If you only want to upload the Git branch that is currently checked out, use the tag --current-branch
(or short name --cbr
).
5、diff
repo diff [project-list]
Use git diff
to show visible changes between commits and the working tree.
6、download
repo download [target change]
Downloads the specified changes from the review system and places them in your project's local working directory for use.
For example, to download change 23823 to your platform/build directory, run the following command:
repo download platform/build 23823
Running repo sync
removes repo download
all commits retrieved using . Alternatively, you can use git checkout m/master
checkout the remote branch.
7、forall
repo forall [project-list] -c command
Runs the specified shell command in each project. repo forall
The following additional environment variables are available via :
- REPO_PROJECT is set to a unique name for the project.
- REPO_PATH is the path relative to the client's root directory.
- REPO_REMOTE is the name of the remote system in the inventory.
- REPO_LREV is the name of the revision in the manifest that was converted to a local tracking branch. Use this variable if you need to pass the manifest revision to a locally running Git command.
- REPO_RREV is the name of the revision in the manifest, exactly as it appears in the manifest.
Options:
- -c: Command and parameters to be executed. This command is evaluated against /bin/sh and any arguments after it are passed as shell positional arguments.
- -p: Display project headers before the output of the specified command. This is accomplished by binding pipes to the command's stdin, stdout, and sterr streams, and then piping all output into a continuous stream that is displayed in a single-page session.
- -v: Display the messages written by this command to stderr.
8、prune
repo prune [project-list]
Prune (delete) merged topics.
9、start
repo start
branch-name [project-list]
Create a new branch for development starting from the revision specified in the manifest.
The BRANCH_NAME parameter is used to briefly describe the changes you are trying to make to the project. If you don't know, consider using the name default .
The project-list parameter specifies the projects that will participate in this topic branch.
10、status
repo status [project-list]
For each specified project, compares the working tree to the staging area (index) and HEAD
the most recent commit on this branch ( ). Displays a summary line for each file that differs between these three states.
To view the status of the current branch, run repo status
. Status information is listed by project. Each file in the project is represented by a two-letter code:
In the first column, a capital letter indicates the difference between the staging area and the state of the last commit.
letter | meaning | illustrate |
---|---|---|
- | no change | Same in HEAD as in index |
A | added | Does not exist in HEAD, but exists in the index |
M | already edited | exists in HEAD, but the file in the index has been modified |
D | deleted | exists in HEAD but not in the index |
R | renamed | does not exist in HEAD, the path to the file in the index has changed |
C | Copied | Does not exist in HEAD, copied from another file in the index |
T | Mode has changed | HEAD is the same as in the index, but the schema has changed |
U | Not merged | Conflict between HEAD and index; needs to be resolved |
In the second column, lowercase letters indicate the difference between the working directory and the index.
letter | meaning | illustrate |
---|---|---|
- | new/unknown | does not exist in the index but exists in the working tree |
m | already edited | exists in the index and also exists in the working tree (but has been modified in both locations) |
d | deleted | exists in the index but not in the work tree |
11. Handle repo errors
git commit -a # Commit local changes first so they aren't lost.
repo start branch-name # Start the branch
git reset --hard HEAD@{
1} # And reset the branch so that it matches the commit before repo start
repo upload .
If the command is not run at the beginning of the session repo start
, the system displays an error repo: error: no branches ready for upload
. To revert, you can check the commit ID, create a new branch, and merge it.