# How to Manage source across Android Versions



## zer0day (Mar 19, 2012)

I'd like to start off by saying that I'm not new to android developement. I have created my own ROM that I used on my Galaxy Nexus but I have a problem that should be easy to fix. I am not an expert with source code management and I believe that is where my problem lies.

What I have done so far:

I have downloaded AOSP (4.1.1_r4) and made my changes to the source code. I have a bitbucket account that I used to upload my changes to. I've compiled my ROM and it works perfectly.

My question now is how do I update my AOSP to 4.1.1_r6 and keep the changes that I have already made? I know I can run the following commands listed below to get the new source but I believe that overwrites my changes and also my modified manifest.xml file.

repo init -u https://android.goog...atform/manifest -b android-4.1.1_r6
repo sync

Any help would be greatly appreciated.


----------



## yarly (Jun 22, 2011)

Start a new branch


----------



## zer0day (Mar 19, 2012)

Can you please be more specific? Do you mean run repo forall -c git checkout -b <new branch name> then run the repo init command and repo sync? Do I then merge this branch back into my original branch?


----------



## yarly (Jun 22, 2011)

Read the following and it will help:

http://source.android.com/source/version-control.html

http://wiki.cyanogenmod.com/wiki/Howto:_Gerrit (especially under examples)


----------



## imnuts (Jun 9, 2011)

You will need to fetch the AOSP remote to get all the changes that have been made between now and the last time you synced. After that, you can use git-merge to merge in the changes. If you are currently on android-4.1.1_r4 (with your own changes) and you want to pull in the new stuff from android-4.1.1_r6, it would be

```
git merge android-4.1.1_r6
```
Be warned though that there could be failures in the merge. If this is the case, it won't finish the commit and you will need to go through, fix any problems, then add the files that you fixed and finally commit them after you've fixed everything. How easy/hard it will be depends alot on what changes you made and the changes that there are between the two branches/tags.


----------



## PonsAsinorem (Oct 10, 2011)

imnuts said:


> Be warned though that there could be failures in the merge. If this is the case, it won't finish the commit and you will need to go through, fix any problems, then add the files that you fixed and finally commit them after you've fixed everything. How easy/hard it will be depends alot on what changes you made and the changes that there are between the two branches/tags.


A handy way to do this is


```
git mergetool
```
The exact way to do it and what it looks like depends on your mergetool.


----------

