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

查看:196
本文介绍了如何在本地回购切换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。 你看,我没有用-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.

所以,我怎么能转投Android 2.3.7没有回购初始化-b Android的2.3.7_r1和回购同步了?

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

推荐答案

您无法使用回购FORALL 解决这个问题。

You cannot solve this problem using repo forall.

让我们假设确定性您当前的Andr​​oid树是干净的 - 没有任何本地更改或承诺,即回购状态显示什么

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

要正确地切换Android版本,你需要改变的是分公司为您的清单库,像这样的:

To properly switch Android version, all you need to change is branch for your manifest repository, like this:

cd $ANDROID_ROOT
cd .repo/manifests
git branch -av   # see all available branches on origin
# choose one you want, check out to it:
git checkout origin/<my_selected_android_version>

在清单回购协议。请注意,以上命令将创建独立 HEAD 。如果你不喜欢,添加 - 轨道(或 -t 的简称)来创建本地跟踪分支

Note that command above will create detached HEAD in manifest repo. If you don't like that, add --track (or -t for short) to create local tracking branch:

git checkout --track origin/<my_selected_android_version>

更新2014年9月5日: 对于最新版本的回购, git的结帐... 上面会不会像以前那样工作,因为下一个回购同步将恢复清单存储库分支,它使用了在回购的init

UPDATE 2014/09/05: For most recent version of repo, git checkout ... above won't work as before because next repo sync will revert manifest repository to branch which was used at repo init.

但是,这也意味着,现在有更简单的方法做你想要的,即:

But that also means that there is now much simpler way to do what you want, namely:

repo init -b <my_selected_android_version>

这种选择性回购的init -b (不含 -u )将只更新清单分支,否则它不会碰你的树。

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

现在,只需将其同步:

repo sync -j8

和一段时间后,你的Andr​​oid树将切换到另一个版本。

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

此操作的速度主要是由以下因素决定多少 default.xml中清单文件不同,旧的和新的Andr​​oid版本之间 - 因为,如果一些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.

不过,总的来说,这种方法还是比重新初始化全新的Andr​​oid树快多了。

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

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

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