[Android Software Development] TheByteSmasher:
6. Cherry-Picking

6. Cherry-Picking

This is the part that most people really want to know about. What is cherry-picking and how do I do it?

On your local computer, you actually have 2 copies of the online Repo. One is in a hidden directory and the other is the one you work with. That way you can modify your visible local copy and if you want to revert or screw something up, it's usually relatively painless to fix. Cherry-picks modify the visible local directory with the modified/added/deleted information of the cherry. When you revert, you're basically calling back up the information from the hidden directory that has been unchanged.

Here is how to cherry pick:

Open up the AOKP Gerrit at

http://gerrit.sudoservers.com/#/q/status:open,n,z

Find a change you want to add.

This is where you want to be careful. If the change has multiple parts (i.e. [1/2]) You'll want to cherry-pick both parts.

____________________________________________________________________________________________________________________________________

This is what the Open Commit will look like:

____________________________________________________________________________________________________________________________________

Choosing the Commit below the highlight by clicking on the Subject name, The next screen looks like this:

Notice the Commit message, (circled in BLUE) it often contains a brief description of the change.

To the left of the commit message is the basic change info.

***The section entitled Project is the important one.*** This section (Circled in RED) tells you where the cherry pick needs to be downloaded to. For this Commit, it needs to be downloaded to your "/home/YourUserName/aokp_jb/device/asus/grouper" directory.

About halfway down the page, you'll find the download section (Circled in GREEN. Click on the "cherry-pick" label. Now copy the URL underneath by either Ctrl+C or right click and copy.

Now we're going to use the "Open in Terminal" extension we installed earlier. You need to navigate into the aokp_jb/device/asus/grouper directory and right click then select "Open in Terminal" or you can do the same by right clicking on the grouper folder and selecting "Open in Terminal"

____________________________________________________________________________________________________________________________________

Once the terminal is open, paste the URL at the command prompt. Either with a right click and paste or Ctrl+Shift+V.

Press Enter

If successful, You should see this or a similar message:

____________________________________________________________________________________________________________________________________

If you want to cherry pick into the same directory as an active pick, you'll need to commit those changes first:

The easiest way is open a terminal in the folder containing the pick you want to commit and type

git add -A

then

git commit -a

Select the files you want to keep and press Ctrl+O (like save) and enter, the Ctrl+X to exit.

When you're done picking go back to the root aokp_jb folder and build!

===================================================================================================================

**In order to sync, you'll need to revert your cherry picks, so sync completes successfully. To do this, type the following in a terminal in each directory you picked into.**

git reset --hard HEAD && git clean -f && git checkout aokp/jb-mr1

This can also be split up into 3 different commands.