Android 什么是 Repo 以及 Google 为什么使用它?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2450601/
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 is Repo and Why does Google use it?
提问by Osama Gamal
When I wanted to get Android source code, I knew that I have to use "repo". So what is repo? Why do they use repo and not just use GIT?, and is there a GUI for repo that enables me to pause/resume syncing, because every time I get disconnected occasionally it seems that repo starts syncing from the beginning!
当我想获得 Android 源代码时,我知道我必须使用“repo”。那么什么是回购?为什么他们使用 repo 而不仅仅是使用 GIT?,并且是否有 repo 的 GUI 可以让我暂停/恢复同步,因为每次我偶尔断开连接时,repo 似乎从头开始同步!
采纳答案by brabster
Repo and git - what they are, what they are for - is explained on source.android.com
Repo 和 git - 它们是什么,它们的用途 - 在source.android.com上有解释
To work with the Android code, you will need to use both Git and Repo.
Git is an open-source version-control system designed to handle very large projects that are distributed over multiple repositories. In the context of Android, we use Git for local operations such as local branching, commits, diffs, and edits.
Repo is a tool that we built on top of Git. Repo helps us manage the many Git repositories, does the uploads to our revision control system, and automates parts of the Android development workflow. Repo is not meant to replace Git, only to make it easier to work with Git in the context of Android. The repo command is an executable Python script that you can put anywhere in your path.
要使用 Android 代码,您需要同时使用 Git 和 Repo。
Git 是一个开源版本控制系统,旨在处理分布在多个存储库中的超大型项目。在 Android 环境中,我们使用 Git 进行本地操作,例如本地分支、提交、差异和编辑。
Repo 是我们建立在 Git 之上的工具。Repo 帮助我们管理许多 Git 存储库,上传到我们的版本控制系统,并自动化部分 Android 开发工作流程。Repo 并不是要取代 Git,只是为了让在 Android 环境中使用 Git 更容易。repo 命令是一个可执行的 Python 脚本,您可以将其放在路径中的任何位置。
There's no GUI for Repo, as far as I can tell, but there's quite a bit of guidance on the site above for controlling what Repo is doing from the command line.
据我所知,Repo 没有 GUI,但是上面的站点上有很多指导可以控制 Repo 从命令行执行的操作。
回答by Matias Burni
As is mentioned in the android webpage, repo
does not replace git
. It is just a tool over git
and helps you to manage multiple git repositories.
正如 android 网页中提到的,repo
不会替换git
. 它只是一个工具git
,可以帮助您管理多个 git 存储库。
For example, suppose I have a big project which has a lot of features and I have several teams working on each feature and I created one repository for each feature. For example suppose my repositories are wifi
, telephony
, power management
, etc. This action has sense when your features have different life cycles. For example if I won't touch the wifi
feature in my next release and but I will modify all the rest. So under this scenario, my project or product is distributed in several different git repositories.
例如,假设我有一个包含很多功能的大项目,并且我有多个团队在处理每个功能,并且我为每个功能创建了一个存储库。例如,假设我的存储库是wifi
、telephony
、power management
等。当您的功能具有不同的生命周期时,此操作是有意义的。例如,如果我不会wifi
在我的下一个版本中触及该功能,但我将修改其余所有内容。所以在这种情况下,我的项目或产品分布在几个不同的 git 存储库中。
So, to get a centralized photo of my project (one specific moment of my project, for example a milestone), I need to get the revision (git hash or tag) of each repository. Remember that we have one repository for each feature. Manually I could do it but could be very painful. So, with repo you can have one MANIFEST
which links to all the revisions of each git repo (one for each feature) and have an specific picture of my whole project.
因此,要获得我的项目的集中照片(我的项目的一个特定时刻,例如里程碑),我需要获取每个存储库的修订版本(git hash 或 tag)。请记住,我们为每个功能都有一个存储库。手动我可以做到,但可能会非常痛苦。因此,使用 repo,您可以拥有一个MANIFEST
链接到每个 git repo 的所有修订版(每个功能一个),并拥有我整个项目的特定图片。
Simply, I could say that is a way to manage centralized multiple git repositories which are decentralized.
简单地说,我可以说这是一种管理分散的集中式多个 git 存储库的方法。
With repo you have more features, not only to checkout at a specific point. For more info go to http://source.android.com/source/using-repo.html.
使用 repo,您可以拥有更多功能,而不仅仅是在特定点结帐。有关更多信息,请访问http://source.android.com/source/using-repo.html。
回答by Jordan Craig
Concerning the pause and restart point, whilst in a terminal window doing a repo sync you can hit, "ctrl + z" to pause the repo sync. To restart simply type "fg" into the same window.
关于暂停和重启点,在终端窗口中执行 repo 同步时,您可以点击“ctrl + z”来暂停 repo 同步。要重新启动,只需在同一窗口中键入“fg”。
回答by Peter Teoh
Go to:
去:
http://source.android.com/source/git-repo.html
http://source.android.com/source/git-repo.html
and you can download the repo
script. It is a Python script that uses the git
command to do distributed source code revision.
你可以下载repo
脚本。它是一个 Python 脚本,使用该git
命令进行分布式源代码修订。
After you have executed repo sync
, do a ps -auwf
to see the processes:
执行完后repo sync
,执行 aps -auwf
查看进程:
For mine I saw:
对于我的,我看到了:
\_ python -E /sde3/root/download/android/android/.repo/repo/main.py --rep \_ git fetch korg \_ git fetch korg \_ git index-pack --stdin -v --fix-thin --keep=fetch-pack 5227 on
\_ python -E /sde3/root/download/android/android/.repo/repo/main.py --rep \_ git fetch korg \_ git fetch korg \_ git index-pack --stdin -v --fix-thin --keep=fetch-pack 5227 on
Yes, repo sync
breaks often. But it is robust, just restart the command and it will resuming syncing again - those that have been updated will not be re-applied, so it will skip over them and continue with the rest.
是的,repo sync
经常休息。但它很健壮,只需重新启动命令,它就会再次恢复同步——那些已经更新的将不会被重新应用,所以它会跳过它们并继续其余的。
回答by user3913384
repo sync has various useful options:
回购同步有各种有用的选项:
-f recovers from disconnects
-f 从断开连接中恢复
-c just uploads the branch you asked for
-c 只是上传你要求的分支
-j <#CPUS> speeds up the sync by increasing the number of cpus used by the command
-j <#CPUS> 通过增加命令使用的 CPU 数量来加速同步