问题现象
在我们使用repo sync的工程中,由于各种原因同步时间比较久,可能导致各种中断情况,如停电,控制台各种原因被关闭等。再次重新同步就可能出现如下问题。
我们分析下日志中的错误输出信息:
“Another git process seems to be running in this repository”
- 这个提示说明在某个仓库中存在一个未完成的 Git 进程(如
git commit
或git fetch
等),导致后续操作被阻塞。
“error: device/google/coral-kernel”
在 device/google/coral-kernel
目录下,Git 无法正常 checkout 到指定的 commit:e1914de3e6f618cb796b370d3ecfb9b739138871
。
“error: Unable to fully sync the tree”
提示无法完成整个同步操作,表明有一些仓库无法正确拉取或更新。
Failing repos:
列出了几个失败的仓库:
cts
device/google/comet-kernels/6.1
device/google/coral-kernel
解决
根据上图提示的信息,我们把同步失败的目录和对应的git删除,再次同步应该就OK了。
rm -rf .repo/project/device/google/coral-kernel
rm -rf device/google/coral-kernel
rm -rf .repo/project/cts.git
rm -rf cts
...
也可以单独删除对应的模块再同步:
rm -rf .repo/project/device/google/coral-kernel
rm -rf device/google/coral-kernel
repo sync device/google/coral-kernel
分析
错误主要是由于某些仓库在 Git 操作过程中未正常结束,或网络、磁盘等系统资源不足导致的,尤其是在同步AOSP这样大规模的项目时。导致的结果包括如: .git/index.lock
文件或其他锁定文件没有被正常删除,阻止了新的 Git 操作;本地仓库的状态不一致或数据损坏,导致 git
操作失败等等。