How to switch android version in local repo?

后端 未结 2 1850
伪装坚强ぢ
伪装坚强ぢ 2021-02-01 21:57

I have downloaded whole working tree with the following command:

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

相关标签:
2条回答
  • 2021-02-01 22:25

    if the branch you are in and the branch you will switch to has the same manifest.xml file, then you can use the following commands to do that.

    repo forall -c git fetch aosp --tags 
    repo forall -c git checkout -b john5.1.1_r14_api22 android-5.1.1_r14
    

    also see details in http://johnliao52.github.io/2016/03/27/git-repo-skills.html

    0 讨论(0)
  • 2021-02-01 22:42

    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.

    0 讨论(0)
提交回复
热议问题