在使用 git-repo 管理程式碼時, 如果 git project 很多或 git object store 很大 (e.g. linux kenrel), 在 repo sync
時間就會花上許多時間 fetch code.
一個加速的方法是利用 git clone
的 reference
功能, 參考 local 已 sync 過得 repo repository 裡的 git database:
git pack-objects
將必要的 objects 打包傳到到新的 repo repository.git fetch
將 remote repository 上新的 commits 抓下來快速藉由 local repo projects 來 sync 所有 projects, 且新的 repo projects 擁有獨立的 git object stores
repo init -u MANIFEST_REPOS -m MANIFEST --reference=/PATH/TO/LOCAL/REPO/REPOSITORY --dissociate
repo sync
--reference
指定已在 local 下載好的 repo repository 位址.
--dissociate
代表 repo 在 git clone 完所有 projects 後, 不會再參考 local repo repository 的 git object store.
之後 repo sync
也會直接從 remote repository fetch.
這樣可以避免被 reference 的 local repo repository 被移除後, 後下載的 repo repository 的 git object store 損毀的狀況發生.
另一種做法是和現有的 local repo projects. 這種方法的優點是可以減少硬體空間, 但是被 shared local repo projects 要小心不能被篩除
# Create repo porjects to be sharef
mkdir matrix; cd matrix
repo init -u MANIFEST_REPOS -m MANIFEST
repo sync
# Share object store with the matrix prokect
repo init -u MANIFEST_REPOS -m MANIFEST --reference=/PATH/TO/MATRIX
repo sync
Repo
Git
Written on
July
13th,
2022
by
Borting