Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to switch android version in local repo?

I have downloaded whole working tree with the following command:

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

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.

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

like image 811
Jiaqi Liu Avatar asked Dec 23 '12 02:12

Jiaqi Liu


People also ask

How do I change branches in repository?

In some cases, you may be interested in checking out remote branches from your distant repository. In order to switch to a remote branch, make sure to fetch your remote branch with “git fetch” first. You can then switch to it by executing “git checkout” with the “-t” option and the name of the branch.

Does repo sync overwrite local changes?

repo sync does not overwrite local changes, so I don't think you're doing what you think you're doing.

What is repo forall?

repo forall [ project-list ] -c command. Executes the given shell command in each project. The following additional environment variables are made available by repo forall : REPO_PROJECT is set to the unique name of the project. REPO_PATH is the path relative to the root of the client.


1 Answers

You cannot solve this problem using repo forall.

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

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

Select a version and

cd $ANDROID_ROOT
repo init -b <my_selected_android_version>

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

Now, simply sync it:

repo sync -j8

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

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.

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

like image 200
mvp Avatar answered Sep 20 '22 12:09

mvp