# When to edit code to put in a tweak to CM for personal use?



## k.electron (Aug 17, 2011)

Hello,

I am trying to build CM10 with a slight hack for my personal use (not distributing).

this is the guide im following

http://mobile.cs.fsu.edu/compile-cyanogenmod-10-for-nexus-7/

and this is the code tweak i wanted to add:

http://forum.xda-developers.com/showthread.php?t=1780970

now the question is: at what point do i go and mess with the java files? before the brunch? or before the build/env....


----------



## Jubakuba (Sep 8, 2011)

After you repo sync.
Make sure you commit your changes...
And build.
Profit.


----------



## k.electron (Aug 17, 2011)

wait.. what? commit changes?

ive never used git, but from cvs land, commit means to put it back on the server.. which i dont think i can do to the cm repo server.


----------



## yarly (Jun 22, 2011)

k.electron said:


> wait.. what? commit changes?
> 
> ive never used git, but from cvs land, commit means to put it back on the server.. which i dont think i can do to the cm repo server.


Git is a distributed repository system, unlike cvs or svn. You host your own repository locally as well as remotely. You just don't push them remotely back and only commit locally. Then you stash your changes (stash being a command you run with git) when you update (using repo sync).

Basically something like:

1) create new branch (*repo start insert-branch-name*)
1a) verify it worked (*repo status*)
1b) assign the branch to the project in question (e.g. frameworks/base/) *repo start insert-branch-name project-name-here* (where project name is frameworks/base or packages/application/browser). Note that those project names may not be 100% correct. I'm not near my build box right now so I can't get specific names. They should be whatever they're called on github though.
1c) switch from the master branch to your newly created branch (using *git checkout insert-branch-name*)
1d) *git branch* will show you which branches you can use just for hints (that or *repo branches*)
2) edit files in branch you created (if not in that branch, assign another project to the branch)
2a) if you run *repo sync* before committing your files (see below) you'll have to stash them first (using *git stash* and then *git stash apply* after syncing)
3) add the files to the branch (*git commit -am "commit message for your own reference here" . *(the dot represents the current directory)
4) commit the changes to your local repository using the command from #3. Note you must run git commands within the project directory (look for a .git directory there, if you dont see one, you're in the wrong directory), unlike repo.
5) if you get errors while trying to sync later on, make sure you added and committed all your changes back locally. If still getting issues after being sure, thenrebase using* git rebase --continue*

Hopefully that is some help to you. Also going to move your topic to the developer forum so others will see it besides me and post. N7 forum might not get too many with developer experience there.

There's way more commands involved than what I listed, but that's the gist of what you should do to track your changes and keep them sane. Also if you're code editing, you can use an IDE like intellij with git integration. Sometimes I have to fall back to the command line every now and then, mainly for repo commands, but the main stuff you would do like commiting and reading logs, etc is much easier to do in an IDE where you can see it with a bunch of easy to use shortcuts like so (see attached). I don't reccomend an IDE though unless you have a pretty powerful computer. It'll take forever to initially load and index, but after that, it's fine. By taking forever, I mean anywhere from 10-40minutes or more depending on your hard drive and CPU speed. While it loads, go get coffee or something, lol.


----------



## k.electron (Aug 17, 2011)

ah.

well ok then.

i'll google the command to commit locally and stash. unless u want to just tell me


----------



## yarly (Jun 22, 2011)

Also: http://www.spheredev.org/wiki/Git_for_the_lazy


----------



## Kevin3328 (Aug 22, 2011)

Yarly... this is fantastic.. I've been looking for a guide like this link u just posted... thanks a bunch!!!

Sent from my Galaxy Nexus using RootzWiki


----------



## yarly (Jun 22, 2011)

Kevin3328 said:


> Yarly... this is fantastic.. I've been looking for a guide like this link u just posted... thanks a bunch!!!
> 
> Sent from my Galaxy Nexus using RootzWiki


Sure, np. There's also some android specific stuff on google's site: http://source.android.com/source/version-control.html

Also:

http://git-scm.com/book
http://gitref.org/

And since so many seem to be in love with cherry picking these days, this one will probably be relevant for many:

http://stackoverflow.com/questions/5120038/is-it-possible-to-cherry-pick-a-commit-from-another-git-repository


----------



## Kevin3328 (Aug 22, 2011)

Lol... yea I'm just trying to learn git for personal use.. don't expect any ROMs from my end any time soon.. although cherry picking looks like fun lol

Sent from my Galaxy Nexus using RootzWiki


----------



## k.electron (Aug 17, 2011)

yeah once u get ubuntu to behave itself inside virtualbox.. took me like 4 tries to get the silly guest additions working so i could copy paste..

also.. if you are heading down the virtualbox path, use a bridged adapter. the nat one seems to have issues syncing the repo.

oh and thanks yarly for the great info.


----------



## JBirdVegas (Jun 11, 2011)

yarly said:


> git add -m "commit message for your own reference here" .


Nice!
I didn't know you could use git add to do the actual commit, saves me a step thanks Yarly


----------



## yarly (Jun 22, 2011)

JBirdVegas said:


> Nice!
> I didn't know you could use git add to do the actual commit, saves me a step thanks Yarly


I was half asleep when I posted that, should be *git commit -am "some message here for the commit" *

That will auto add all modified files and commit them.


----------

