Android source是large hierarchy of git repositories。它們由一個名爲repo的自定義腳本管理。 Repo使用manifest.xml來確定要管理的git存儲庫。 manifest.xml of Android與所有其他git存儲庫一起託管在git存儲庫中。Android倉庫清單存儲庫如何工作?
這個存儲庫在Android中如何管理?具體來說,每個分支中託管的不同分支和不同文件是如何組織的?
Android source是large hierarchy of git repositories。它們由一個名爲repo的自定義腳本管理。 Repo使用manifest.xml來確定要管理的git存儲庫。 manifest.xml of Android與所有其他git存儲庫一起託管在git存儲庫中。Android倉庫清單存儲庫如何工作?
這個存儲庫在Android中如何管理?具體來說,每個分支中託管的不同分支和不同文件是如何組織的?
在repo的根目錄下是一個名爲「.repo」的隱藏目錄,在裏面你會發現一個名爲「manifests」的git項目,它通常包含一個名爲「default.xml」的文件。該文件包含有關所有項目的信息以及其關聯的git存儲庫所在的位置。這個文件也是版本化的,因此當你使用「repo init -b XYZ」命令時,它將被恢復,並且你可以回到可能已經添加/刪除了git項目的老分支。
下面是回購git倉庫文檔的鏈接描述清單格式:
https://gerrit.googlesource.com/git-repo/+/master/docs/manifest-format.txt
首先,回購INIT創建.repo
目錄,克隆git倉庫https://android.googlesource.com/tools/repo到.repo/repo
,並指定了git倉庫將-u
選項設置爲.repo/manifests.git
的裸倉庫。之後,它創建.repo/manifests
目錄,通過創建從.repo/manifests/.git
到.repo/manifests.git
的符號鏈接將其轉換爲git存儲庫。然後檢出-b
中指定的分支,並創建一個符號鏈接.repo/manifest.xml
指向.repo/manifests
中的指定文件(-m
選項),默認爲.repo/manifests/default.xml
。
大致如下:
repo init -u $URL -b $BRANCH -m $MANIFEST -------------------- mkdir .repo; cd .repo git clone https://android.googlesource.com/tools/repo git clone --bare $URL manifests.git mkdir -p manifests/.git; cd manifests/.git for i in ../../manifests.git/*; do ln -s $ı .; done cd .. git checkout $BRANCH -- . cd .. ln -s manifests/$MANIFEST manifest.xml
您可以跟蹤真正與repo --trace init ...
然後發生,回購同步克隆Git倉庫,以.repo/projects
爲manifest.xml
和local_manifest.xml
每一個項目,創建工作目錄具有.git
符號鏈接到相應的裸存儲庫,檢出清單中指定的分支,並更新.repo/project.list
。項目已經存在的情況稍有不同,基本上執行git pull --rebase
。
很想聽聽他們爲什麼要這樣做的解釋!特別是,將'.repo/projects /'內的所有'.git'內容存儲起來有什麼好處? – Hamy 2015-07-31 01:37:54
我不知道爲什麼'repo'背後的人選擇了他們所做的方法。有了某些版本的'repo',就可以在不同的構建樹之間共享'.repo/projects'目錄,這對於使用小型硬盤的筆記本電腦來說非常方便。但是這從來沒有得到支持,我不知道它是否可以工作。 – 2015-08-29 09:40:58
@Hamy - 它允許一個rm -fr可見的項目構建目錄而不會丟失git對象,因此後續的repo同步將會很快。 – 2017-10-10 10:09:56
鏈接斷開。 – 2015-04-23 11:01:58