[Android Software/Hacking General [Developers Only]] gokussjx:
STEP 3: The After-life: Git, Gerrit, Patch Submissions:

-Credits to D4rKn3sSyS, for the Git tutorial below-

STEP 3: The After-life: Git, Gerrit, Patch Submissions:​

As many of you know, our gerrit is officially up since a few days ago here, so here's a simple how-to for pushing changes to gerrit, mostly taken from here.

If you make any changes, or want to officially maintain PA for a new device, this is where you upload your changes.

You must create a gerrit account first, and add your ssh keys to Settings > SSH Public Keys

Guide on how to generate ssh keys (Only generating part, ignore adding to github)

https://help.github.com/articles/generating-ssh-keys

# Submitting changes:

1) First, you need to start a topic branch. This 'branch' holds the changes you make to the files on your computer that you will ultimately send to the ParanoidAndroid servers for review. Create your topic branch:

$ repo start [COLOR="Red"]<branch name> <project name>[/COLOR]

Note: This starts a new branch called '<branch name>' in the '<project name>' project. Replace <project name> with the name of your target repository instead.

2) Now, you can cd to the project (directory) that contains the file(s) you want to edit:

$ cd ~/android/system/[COLOR="red"]path/to/project[/COLOR]

Now you can make your changes. Make sure you do not edit any files before you run repo start, or your changes will happen on a different branch and will not be tracked correctly.

3) After you make your changes, you can commit them just as you would normally:

$ git add -A
$ git commit -a
$ cd ~/android/system

4) Now you can upload your changes to the ParanoidAndroid server:

$ repo upload [COLOR="red"]<project name>[/COLOR]

That's it! Your change will be reviewed and may be accepted or rejected.

ProTip: The first line of your commit message will become the Change's Title. Add a blank space after the Title and write the summary of changes there. Make sure that the change's title and summary width do not exceed 80 chars per line.

# Submitting patch sets:

-> It's a common case. Your patch has issues or errors, which are noted in the code review, so you will want to resolve them. Sometimes it's just tabs instead of spaces or typos in strings and variable names.

-> Before you edit those files, type in

$ git branch -v

to make sure you are on the correct branch.

-> If you are not in the correct branch or in no branch at all, type in

$ git checkout [COLOR="red"][branchname][/COLOR]

to switch to the correct branch.

-> Now you can edit the files. After you made your changes, do the usual

$ git status

and notice that git diff will only show you the changes you just made. Once you are satisfied, you can prepare the upload.

-> Add the files that you've modified by using

$ git add -A

.

-> To Upload, type in

$ git commit --amend

.

This will open an editor with your initial commit message.

-> You can also change the commit message if you want to, but make sure the last two lines stay as are. They contain the initial commit ID and a blank line. With this id, Gerrit will detect your upload as a patch set and not as a new patch.

-> You can do

$ git log

and

$ git status

again.

Notice how Git handles your initial commit and the commit using --amend as one patch. Same for git show. It will show you all the changes, your initial patch & the patch set you just committed, as one patch.

-> Now you can submit you patch set to your initial patch with

$ repo upload [COLOR="red"]<project name>[/COLOR]

ProTip: If this fails and you get two different reviews on gerrit, abandon the oldest one, you make reviewer life easier!.

# How to know latest commit ID on github project:

-> Open project, example, for frameworks:

https://github.com/ParanoidAndroid/android_frameworks_base

Youll see this, wich is latest commit ID

---Common issues---

Permission denied (publickey): Make sure you have ssh keys and your local git username matchs with gerrit username. Is everything correct but you still have issues?, try with "ssh-add" command, or changing your RSA key by a DSA key

no branches ready for upload: you must do the following steps

$ cd ~/android/system
$ repo abandon [COLOR="red"]<branch> <project>[/COLOR]
$ repo start [COLOR="red"]<branch> <project>[/COLOR]
$ cd ~/android/system/[COLOR="red"]path/to/project[/COLOR]
$ git reset --hard [COLOR="Red"]<latest-github-commit-id>[/COLOR]

MAKE OR RESTORE YOUR CHANGES AND COMMIT

$ cd ~/android/system
$ repo upload [COLOR="red"]<project>[/COLOR]