repo syncThe command will synchronize all git repositories of Android source code by default. If you want to synchronize one or more git repositories separately, you can provide one or more project parameters to specify the path of GIT repository to be synchronized. The specific command format is as follows:
- Usage: repo sync [<project>…]
The key is how to know the value of the project parameter corresponding to a git warehouse, the subdirectory name of the GIT warehouse, the full directory path of the GIT warehouse stored in repo, or others?
After the actual test, it is found that the project parameter value provided here is based on the directory path from the current shell’s working directory to the target git warehouse, rather than the full directory path saved by git warehouse in repo, or the subdirectory name of GIT warehouse.
For example, execution
repo statusThe command prints the following git repository information:
project android/packages/apps/Settings/ branch branch_m -m res/values-zh-rCN/strings.xml
As you can see, the full path of the GIT repository in repo isandroid/packages/apps/Settings/, whose subdirectory name isSettings。
cdOrder to enter intoandroidThe test is as follows.
1. In the currentandroidExecute under subdirectory
repo sync android/packages/apps/Settings/Command, an error will be reported:
$ repo sync android/packages/apps/Settings/ error: project android/packages/apps/Settings/ not found
That is, the working directory of the current shell is inandroidUnder the subdirectory, put the GIT warehouse to be synchronized in the full directory path of repoandroid/packages/apps/Settings/If it is passed to the repo sync command as a parameter, an error will be reported. Based on this path, the GIT warehouse to be synchronized cannot be located.
2. Introductionpackages/apps/Settings/This path can be executed normally:
$ repo sync packages/apps/Settings/ Fetching project platform/packages/apps/Settings/
Based on the current locationandroidSubdirectory, you can locate the given directory normallypackages/apps/Settings/Git warehouse under the path.
cdOrder to enter intoandroid/packages/apps/Settings/Directory, and then execute
repo sync .Command will not report error:
$ repo sync . Fetching project platform/packages/apps/Settings/
Based on these test results, we can find that the project parameter value following repo sync should be based on the directory path that the current shell working directory can address to the GIT warehouse, similar to the path addressing method of CD command.
Check the help information printed by the repo help sync command. The description of the project parameter is as follows, which conforms to the above verification results:
‘repo sync’ will synchronize all projects listed at the command line. Projects can be specified either by name, or by a relative or absolute path to the project’s local directory. If no projects are specified, ‘repo sync’ will synchronize all projects listed in the manifest.
That is, you can provide the project name, or provide a relative path or absolute path that can be addressed to the local directory of the project to specify the project to be synchronized.
The project name mentioned here is not the subdirectory name of GIT warehouse. The specific value should be generated by repo command
.repo/View under the directory. For example, view
.repo/The manifest.xml file in the directory contains the following information:
<project groups="p-fs-release,pdk-fs" name="platform/packages/apps/Settings" path="android/packages/apps/Settings" />
As you can see,SettingsThe complete path of GIT repository in the subdirectory in repo isandroid/packages/apps/Settings, which is consistent with the information printed in the above example. And its name isplatform/packages/apps/Settings。
As long as the working directory of the current shell is a subdirectory of the Android source code, no matter which subdirectory it is in, execute
repo sync platform/packages/apps/SettingsThe command will synchronize the code of GIT repository settings. We will not give an example here. We can verify it by ourselves.