Before venturing any further into the land of source code changes, it is probably best to have somewhere to store your code and changes in an incremental fashion. This provides a lot of benefits and is always advisable when working with a large project like the AOSP but the main benefit for me is the ability to see which files you have edited at any given time and what changes you have made. Before I setup my own repositories I made a lot of little changes here and there and then completely forgot about what I had done a few days later.
So the two main (and free) GIT repository sites are github and Bitbucket. So go ahead and sign up for one of those; I use bitbucket as they allow you free private repos that nobody else can see and this is useful for some of my projects but the whole point of AOSP is that it’s open source so a public repo will do just fine.
Once you have signed up to one of those the process is pretty straight forward. The two sections of code we want to store for now are the frameworks/base structure and the device/htc/flounder (or whatever your specific device structure is).
Create a repo inside your account and all it ‘frameworks/base’ or something similar.
On both sites you will be given basic instructions on how to initialize and populate the GIT repo you have just created. All we want for now is the address of it I.e. https://github.com/username/test
Open up a terminal and go to frameworks/base
Run the commands below to set up your repo and push your code to the remote repository. This can take quite awhile the first time depending on your internet connection but it is completely worth it.
Note: if you don’t have Git installed you can do so by running the following from a terminal:
sudo apt-get update sudo apt-get install git
Agree to any prompts that may appear.
git init git checkout -b master git add --all git commit -m "initial commit with power menu changes" git remote add origin [address of the repo you created] git push -u master
‘git init’ initialises that directory and everything below it as a git repo.
‘git checkout -b master’ create a local branch called master and checks it out.
‘git add –all’ stages all the changes we have made. Gets them ready to commit.
‘git commit -m …” commits are changes to the branch with a message in between the double quotes.
‘git remote add…’ adds the remote repository that you created to this repos list of remote repositories.
‘git push -u master’ pushes all of our changes and everything under the frameworks/base directory to our remote git repository.
If you run ‘git remote -v’ you will see a list of remote repos that this local repo can communicate with. Currently you should see AOSP (the official repo that you can pull from) and origin which you have just created to represent your own remote repo.
Repeat the same steps for your device branch. These are the two most common places that you will be making changes for now.
From now on, any time you make changes below the frameworks/base folder for example, you can go to the frameworks/base folder and run:
cash status
to see what files you have changed. You can then see exactly what changes you have made by running:
git diff path/to/file/filename
Once you’re happy with your changes you can add everything to your commit by running:
git add --all
Or just add some files one-by-one with:
git add path/to/file/filename
Once you are ready to commit simply run:
git commit -m "I have changed....x..y..z"
And finally push it to your remote repo with:
git push origin