Switching Git branches inside an Android Repo project

I have a question about switching branches using repo . I know that I can check out a branch like this:

$ repo init ... -b foo $ repo sync 

I understand that this will check the foo branch of the manifest store and then check the git projects as described in the manifest.

I also understand that I can switch branches like this:

 $ repo init ... -b bar $ repo sync -d 

My question is: can I switch between branches without synchronizing repos and repos, and what are the consequences of this?

Let me illustrate an example:

 $ repo init ... -b foo $ repo sync -d $ repo start foo-mytopic proj1 proj2 ... make some commits ... $ repo upload -t $ repo init ... -b bar $ repo sync -d $ repo start bar-topic proj1 proj3 $ repo upload -t $ cd proj1 $ git checkout foo-mytopic # IS THIS ALLOWED? 

I tried this before and it seems to work, but it is a bit strange, because now I checked the code that was in the manifest foo , but my current manifest branch is the bar . What are the consequences of staying on a different branch than described in the manifest?

Note. I read this one and I think my question is different. I know how to switch between branches. I am interested in the consequences of being on a different branch than those described in the current manifest, and how this might affect my workflow.

+6
source share
1 answer

Since no one else could answer this, I did some more research and experimentation. Here is what I found:

Tl; dr - Certain teams will do strange things. Be careful when using repo sync and repo start . Try to stick with simple git commands. repo upload should work.

The repo documentation says repo synchronization is equivalent

 $ git fetch origin $ git rebase origin/<BRANCH> 

where BRANCH is the currently selected branch in the local project directory. However, based on my own experience, the repo will also contact upstream tracking information for this branch based on what is in the current manifest.

To continue the example above, git checkout foo-mytopic actually allowed and will behave appropriately. Downloading the repo will cause changes to the branch that foo-mytopic tracks ( foo ), but synchronizing the repo will change the upstream tracking information. In this situation, it is better to start git fetch origin and git rebase origin/<BRANCH> manually.

the manifest (and branch) described in the init repo will not play until repo sync or repo start executed.

+2
source

Source: https://habr.com/ru/post/988856/


All Articles