Android repo init 和 repo sync 实际上是做什么的?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25046570/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does repo init and repo sync actually do?
提问by Poly Bug
I posted this question at Android Enthusiasts but figured it was the wrong place to ask, so I deleted it from there and asking it "again" here.
我在 Android Enthusiasts 上发布了这个问题,但认为这是一个错误的提问地点,所以我从那里删除了它并在这里“再次”提问。
This is such a noob question, and pardon me if it is, but I just want to understand the underlying concepts clearly. Reading repo help and Google's repo command reference page doesn't really enlighten much. I understood some bits from Google's reference page, but I still need some more clarifications.
这是一个菜鸟问题,如果是,请原谅我,但我只想清楚地理解基本概念。阅读 repo 帮助和 Google 的 repo 命令参考页面并没有真正启发多少。我从谷歌的参考页面中了解了一些内容,但我仍然需要更多的说明。
Following the instructions on how to download android source, I executed these two commands on an Ubuntu shell: (I've taken cared of all the prerequisites for the environment.)
按照有关如何下载 android 源代码的说明,我在 Ubuntu shell 上执行了这两个命令:(我已经考虑了环境的所有先决条件。)
~/android4.2.2$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.2.2_r1.2
~/android4.2.2$ repo sync -j4
After waiting half a day for repo to finish downloading, I ended up with 19G of downloaded material in android4.2.2 directory. So what exactly just happened, and why did it reach 19G when Google said I should only be expecting around 8G of source files?
等了半天repo下载完成,结果在android4.2.2目录下下载了19G的素材。那么到底发生了什么,当谷歌说我应该只期待大约 8G 的源文件时,为什么它达到了 19G?
回答by ozbek
repo
is a python wrapper script for git
, its Google Source pagedefines it as
repo
是一个 python 包装脚本git
,它的谷歌源页面将它定义为
repo - The Multiple Git Repository Tool
repo - 多 Git 存储库工具
repo init
command initializes repo in the current directory. That's, it downloads the latest repo source and amanifest.xml
file that describes the directory structure of the git repositories, and store all of these in.repo
sub-directory in the current directory. In your case, you have used an optional-b
argument which is used to select the branch to checkout. By default (i.e., when-b
argument is not used), master branch is used.repo sync
updates working tree to the latest revision. That's, it synchronizes local project directories with the remote repositories specified in the manifest file. If a local project does not yet exist, it will clone a new local directory from the remote repository and set up tracking branches as specified in the manifest. If the local project already exists, it will update the remote branches and rebase any new local changes on top of the new remote changes.-j
argument is used to set number of parallel jobs to execute. The default value can be defined in the manifest, and also can be overridden in command line as in your case.
repo init
命令初始化当前目录中的 repo。也就是说,它下载最新的 repo 源和一个manifest.xml
描述 git 存储库目录结构的文件,并将所有这些存储.repo
在当前目录的子目录中。在您的情况下,您使用了一个可选-b
参数,用于选择要结帐的分支。默认情况下(即,当-b
不使用参数时),使用 master 分支。repo sync
将工作树更新到最新版本。也就是说,它将本地项目目录与清单文件中指定的远程存储库同步。如果本地项目尚不存在,它将从远程存储库克隆一个新的本地目录,并按照清单中的指定设置跟踪分支。如果本地项目已经存在,它将更新远程分支并将任何新的本地更改重新绑定到新的远程更改之上。-j
参数用于设置要执行的并行作业数。默认值可以在清单中定义,也可以在命令行中像你的情况一样被覆盖。
why did it reach 19G when Google said I should only be expecting around 8G of source files?
为什么当谷歌说我应该只期待大约 8G 的源文件时它达到 19G?
That should be because besides the source files, you will get all the history of Android since the beginning of the time :)
那应该是因为除了源文件之外,您还将获得从一开始就 Android 的所有历史记录:)
Hope this helps.
希望这可以帮助。