简体   繁体   English

repo init 和 repo sync 实际上是做什么的?

[英]What does repo init and repo sync actually do?

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.阅读 repo 帮助和 Google 的 repo 命令参考页面并没有真正启发多少。 I understood some bits from Google's reference page, but I still need some more clarifications.我从谷歌的参考页面中了解了一些内容,但我仍然需要更多的说明。

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.等了半天repo下载完成,结果在android4.2.2目录下下载了19G的素材。 So what exactly just happened, and why did it reach 19G when Google said I should only be expecting around 8G of source files?那么到底发生了什么,当谷歌说我应该只期待大约 8G 的源文件时,为什么它达到了 19G?

repo is a python wrapper script for git , its Google Source page defines it as repogit的 python 包装脚本,它的谷歌源页面将它定义为

repo - The Multiple Git Repository Tool repo - 多 Git 存储库工具

  1. repo init command initializes repo in the current directory. repo init命令初始化当前目录中的 repo。 That's, it downloads the latest repo source and a manifest.xml file that describes the directory structure of the git repositories, and store all of these in .repo sub-directory in the current directory.也就是说,它下载最新的 repo 源和一个描述 git 存储库目录结构的manifest.xml文件,并将所有这些存储在当前目录的.repo子目录中。 In your case, you have used an optional -b argument which is used to select the branch to checkout.在您的情况下,您使用了一个可选的-b参数,用于选择要结帐的分支。 By default (ie, when -b argument is not used), master branch is used.默认情况下(即,当不使用-b参数时),使用 master 分支。

  2. repo sync updates working tree to the latest revision. repo sync工作树更新到最新版本。 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. -j参数用于设置要执行的并行作业数。 The default value can be defined in the manifest, and also can be overridden in command line as in your case.默认值可以在清单中定义,也可以在命令行中像你的情况一样被覆盖。

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.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM