Search code examples
androidrepo

REPO (aosp) switch between branches


I have some issues in understanding how repo works, specifically how to switch between branches.

I did

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

and then

repo sync.

Based on my understanding my repo branch should be on master, but when I run

repo branch

the output is no branches.

I want to know how can I switch between branches. Should I run

repo init and repo sync

every time I want to switch branch (repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1) or is there any similarity with git flow (git checkout <branch>). How can I create new local branch for developing?

Thanks for help.


Solution

  • repo doesn't use branches the same way git does. With repo, you are not on a branch until you start a unit of work with the "repo start" command. repo start puts you on a dev branch based on the head of the branch you specified with the -b option in your repo init command. Once you're done with a local dev branch and you either repo prune it or repo abandon it, you go back to a no branch state (or it can also say you are detached, it means the same thing).