I feel I have a pretty good understanding of git, but when it comes to the repo command, I get lost. I've read about the repo command, but I'm still not sure how it ties everything together.
My biggest question is can I change my current branches from gingerbread to ICS and possibly back?
I see the command:
repo init -u https://android.googlesource.com/platform/manifest
From my understanding, this will create a repo with the master branch. If I want to specify the branch, I can do:
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
The download is about 8GB, I believe, so I don't want to have to blow my repo away if they share code. is there a way to switch branches in repo?
If you run repo init a second time with a different branch, you can simply repo sync and it will not download the entire source code again.
The second time you run repo init, just run it as
repo init -b different_branch
You don't need to provide the -u parameter again.
The repo -b parameter specifies the branch of the .repo/manifests git repository that should be checked out. The default.xml file in this repository defines which branch each of the other git repositiories (projects) should be on.
It seems that repo is written in such a way that if you check out another manifest branch are repo sync again it will pull all the code again over the network.
You can run repo forall -c 'git checkout branch_name' which will checkout the specified branch for all projects that are declared in your current manifest but if there are projects added/removed between gingerbread and ics (which there are), then you won't get the code for these projects.
Running git checkout branchname in the .repo/manifests repository then running repo sync may enable you to save some network overhead.
Otherwise, due to the limitations of repo, the only real way to do it is to maintain two working copies of the aosp or be prepared to re-sync.
Related
I'm trying to build custom rom for my device from CM source.I'm following this guide to build:
https://wiki.cyanogenmod.org/w/Build_for_quark
I'm using this command to sync the source.
repo init -u https://github.com/CyanogenMod/android.git -b cm-12.1
During download i can see other branches like 7,8,9,10,11,12.Is there any way to download only current branch (12.1)?
The repo sync command is same as git clone when used without any flags, that means you are simply downloading all the branches from all the repositories defined in the manifest file (visit this and see the default.xml file).
To download only the current branch that is cm-12.1, use the -c flag while using the repo sync command. Note that the Android source is made from many projects and is a huge download when you are syncing for the first time.
So your commands should be:
repo init -u https://github.com/CyanogenMod/android.git -b cm-12.1
repo sync -c
For a better understanding of how repo tool works just read this article.
I hope this helps.
I'm trying to learn Embedded Android from the book with the same name. And the author suggested working with AOSP gingerbread branch. So I followed to download the source:
$ repo init -u https://android.googlesource.com/platform/manifest.git
-b gingerbread
$ repo sync
But it's taking too long. Also from the output, it seems to me like it's also downloading source code from other branches (I see android-5.....) which is not what I want. I'm wondering if that's the reason why it takes so long.
Has anybody had the same problem? Please give me a suggestion! Thanks!
AOSP is a multi-gigabyte download so there's not that much you can do. However, passing the -c/--current-branch option to repo sync causes Repo to tell Git to only fetch the branch you really need instead of all branches of each repository. With an old release like Gingerbread this should theoretically be quite beneficial. However, Repo seeds the repositories with Git bundles that it downloads via HTTP, and the bundle files aren't affected by the -c option. Using --no-clone-bundle disables the bundle files. Hence the following Repo command should yield the smallest download:
repo sync -c --no-clone-bundle
(Keep in mind that Gingerbread is a several year old release. It won't work out of the box on a lot of recent hardware.)
You should use this commands:
Example: for my personal AOSP Repo,
repo init --depth=1 -u https://github.com/zawzaww/aosp-android.git -b android-8.1.0
and then,
repo sync -f --force-sync --no-clone-bundle --no-tags -j$(nproc --all)
You can learn more on my GitHub Repo
repo init --depth 1
This is another option that might improve sync speed, as it should only download the latest version of the repos.
See also: https://superuser.com/questions/603547/how-can-i-limit-the-size-of-the-android-source-i-need-to-download-with-repo-syn
Here are my full test commands: How to compile the Android AOSP kernel and test it with the Android Emulator?
repo sync -c --no-tags --no-clone-bundle -j2
Shortens my sync times greatly.
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?
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.
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
If I use repo -u init [url] -b gingerbread and executed epo sync, is only the source code of ginerbread is downloaded? As I know, git will actually keep the whole repository. So I suppose if I can do something like git checkout ics to get the ICS source code event I only executed repo -u [url] -b gingerbread.
I am not quite understand how repo command works.
If you only want the single branch use the -c argument. It's also faster and less space will probably be used.
repo sync -c ...
When I give these commands then the 2.3.7 branch gets initialized in current directory and source gets downloaded.
repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.7_r1
repo sync
Thereafter if I give following command what exactly happens
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
or
repo init -u https://android.googlesource.com/platform/manifest
My Questions
Will my earlier branch be deleted which I have downloaded with great difficulty? Cant I have multiple branches existing simultaneously?
If I can have more than one branch then how to access them? I dont see any directory called 2.3.7 or 4.0.1.
The repo directory structure is very confusing. Can anybody guide?
You should start a new repo branch within the same source code branch
repo start BRANCH_NAME [PROJECT_LIST]
Also refer to the following book on how to switch and make use to features in git
Look at section on branching and merging. Create branch using repo and then git commands to move around
You should do a repo init in a different directory. repo init clones the git structure specified by the manifest file
e.g
android/gingerbread/repo init
android/eclair/repo init
I see that you want to sync a new branch while using the files downloaded at previous sync to save download time.
create a new directory
copy the .repo file (hidden) from the old branch_folder (gingerbread in your case) to a new directory
cd into that directory
Finally you can do:
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
repo sync