50

The Android source is a large hierarchy of git repositories. They are managed by a custom script called repo. Repo determines which git repositories to manage using a manifest.xml. The manifest.xml of Android is hosted in a git repository along with all the other git repositories.

How is this repository managed in Android? Specifically how are the different branches and the different files hosted in each branch organised?

4

2 回答 2

66

首先, repo init 创建目录,将 git 存储库https://android.googlesource.com/tools/repo.repo克隆到,并将使用选项指定的 git 存储库克隆到位于 的裸存储库。之后,它创建目录,通过创建从到的符号链接将其转换为 git 存储库。然后,它会检查 中指定的分支,并默认创建指向 中指定文件(选项)的符号链接。 .repo/repo-u.repo/manifests.git.repo/manifests.repo/manifests/.git.repo/manifests.git-b.repo/manifest.xml-m.repo/manifests.repo/manifests/default.xml

大致如下:

  repo init -u $URL -b $BRANCH -m $MANIFEST
  --------------------
  mkdir .repo; 光盘.repo
  git 克隆 https://android.googlesource.com/tools/repo
  git clone --bare $URL manifests.git
  mkdir -p 清单/.git;cd 清单/.git
  对于我在 ../../manifests.git/*; 做 ln -s $ı .; 完毕
  光盘..
  git checkout $BRANCH -- .
  光盘..
  ln -s manifests/$MANIFEST manifest.xml  

您可以追踪真正发生的事情repo --trace init ...

然后, repo sync 为和.repo/projects中的每个项目克隆 git 存储库,创建具有指向相应裸存储库的符号链接的工作目录,签出清单中指定的分支,并更新. 项目已经存在的情况略有不同,本质上是执行.manifest.xmllocal_manifest.xml.git.repo/project.listgit pull --rebase

于 2012-08-08T18:04:34.080 回答
9

At the root of the repo is a hidden directory named ".repo", inside you will find a git project named "manifests" which usually contains a file named "default.xml". This file contains information about all the projects and where their associated git repositories are located. This file is also versioned thus when you use the "repo init -b XYZ" command it will be reverted and you can back to older branches that may have added/removed git projects compared to the head.

Here is a link to the repo git repo document describing the manifest format:

https://gerrit.googlesource.com/git-repo/+/master/docs/manifest-format.txt

于 2012-05-11T09:10:53.613 回答