如何在本地 repo 中切换 android 版本? [英] How to switch android version in local repo?

查看:64
本文介绍了如何在本地 repo 中切换 android 版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用以下命令下载了整个工作树:

I have downloaded whole working tree with the following command:

repo init -u https://android.googlesource.com/platform/manifest
repo sync -j8

同步成功后,我想将工作树切换到 android 2.3.7.你看我在repo init"时没有用-b"参数指定分支.所以我想应该下载所有标签信息,我可以使用以下命令轻松切换到 android 2.3.7:

After syncing successfully, I want to switch working tree to android 2.3.7. You see I didn't specify branch with "-b" parameter when "repo init". So I guess all tag info should be downloaded and I can easily switch to android 2.3.7 with the following command:

repo forall -c git checkout android-2.3.7_r1

但它会产生许多错误,例如:

But it produces many errors like:

error: pathspec 'android-2.3.7_r1' did not match any file(s) known to git.

那么如何在没有repo init -b android-2.3.7_r1"和repo sync"的情况下切换到 android 2.3.7 呢?

So how can I switch to android 2.3.7 without "repo init -b android-2.3.7_r1" and "repo sync" again?

推荐答案

您无法使用 repo forall 解决此问题.

You cannot solve this problem using repo forall.

让我们确定您当前的 Android 树是干净的 - 没有本地更改或提交,即 repo status 没有显示任何内容.

Lets assume for certainty that your current Android tree is clean - no local changes or commits, i.e. repo status shows nothing.

要正确切换 Android 版本,您只需更改清单存储库的分支即可.首先确定具有不同 Android 版本的清单的可用分支:

To properly switch Android version, all you need to change is branch for your manifest repository. First determine the available branches with manifests for the different Android versions:

cd $ANDROID_ROOT
cd .repo/manifests
git branch -av   # see all available branches on origin

选择一个版本并

cd $ANDROID_ROOT
repo init -b <my_selected_android_version>

这种带有-b(没有-u)的选择性repo init只会更新manifest分支,否则不会触及你的树.

Such selective repo init with -b (without -u) will only update manifest branch and will not otherwise touch your tree.

现在,只需同步它:

repo sync -j8

一段时间后,您的 Android 树将切换到另一个版本.

and some time later, your Android tree will switch to another version.

此操作的速度主要取决于新旧 Android 版本之间的 default.xml 清单文件有多少不同 - 因为如果在新清单中添加了一些 git 存储库,它将花费时间克隆它.如果某些存储库被删除,如果真的把它吹走.

Speed of this operation is mostly determined by how much default.xml manifest file differs between old and new Android versions - because if some git repository was added in new manifest, it will spend time cloning it. And if some repository was removed, if will actually blow it away.

但是,总的来说,这种方法仍然比从头开始初始化全新的 Android 树快得多.

But, by and large, this method is still much faster than initializing brand new Android tree from scratch.

这篇关于如何在本地 repo 中切换 android 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆