27

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?

2 Answers 2

60

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.

1
7

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.

1
  • 3
    I realize you posted this a few months ago, but the part about the source being downloaded again is no longer accurate if it was.
    – gparent
    Jul 17, 2012 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.