Android and Github

How to use github for android developmen

Local manifest

In .repo create a file called local_manifest.xml to replace the original parts with your github forks. It should look like:

<?xml version="1.0" encoding="UTF-8"?>
  <remove-project name="Andromadus/android_frameworks_base" path="frameworks/base" />
  <project name="guhl/android_frameworks_base" path="frameworks/base" revision="jellybean" />
  <remove-project name="Andromadus/android_packages_apps_Settings" path="packages/apps/Settings" />
  <project name="guhl/android_packages_apps_Settings" path="packages/apps/Settings" revision="jellybean" />

Local branch and push

Create your local branch to work on:

git remote add origin
git remote show origin

If the remote branches are not shown as tracked do:

git fetch
git remote show origin

Checkout a branch

git checkout -b jb origin/jellybean

Now you can work on your local branch jb and push to the remote origin/jellybean

Update from original repo

Create a remote for the upstream:

git remote add upstream git://

Fetch the remote

git fetch upstream

Merge the changes

git merge upstream/jellybean

Update the fork from the local merge

Syntax is:

git push {remote} {localbranch}:{remotebranch}

which is in my case

git push origin jb:jellybean


create patch from uncommitted stuff

Write down die Hash of the last commit do a temporary commit. create the patch for the temporary commit:

git format-patch -1 <Hash of the temporary commit>

reset the temporary commit:

git reset --mixed <Hash of the commit before the temporary commit>

Check and apply patch

Check the patch:

git apply --check <file.patch>

Apply the pathc with am (that allows to sign off the patch)

git am --signoff <file.patch>

apply a patch an make it uncommitted

On the receiving side apply the patch as described above and the reset to the last commit before the patch using the "git reset --mixed <Hash of the commit before the temporary commit>" again

Squashing several commits into one

After cherry-picking serveral commits into one new clean base one can consolidate the commits into one using the following commands:

In the following example i have been working on the cm-10.2 branch and now want to consolidate all my last commits into one. The result should be in the cm-10.2 branch again.

Move the current branch

git branch -m cm-10.2 cm-10.2_pff

Checkout the original branch again and merge the working branch.

git checkout -b cm-10.2 origin/cm-10.2
git merge cm-10.2_pff

Reset the cm-10.2 branch to the original state.

git reset origin/cm-10.2

Now all the changes are unstaged and one can add and commit them again in one consolidated commit.

git add -A
git commit
Last modified 11 years ago Last modified on 10/21/13 11:28:31