[Android Software/Hacking General [Developers Only]] eagleeyetom:
Pull request

If you feel that you have fixed a problem and want to help the developer to make his own ROM/kernel etc. you should consider to make a pull request. Pull request adds the changes you have made to the others repo.

First of all.

Fork and clone destined repo.

Check the previous post about forking and cloning.

Now make some changes and upload it to your own remote git.

Then, go to your forked repo using browser and click on Pull request.

Then choose the account and branch to pull-request.

Click and wait for your request to be merged :)

Merging a pull request.

Sometimes someone wants to add something to your code.

You'll be notified by e-mail and also see the notification on your github website.

Go there and click Open

When the changes can't be merged you'll see such message:

But when it's green, you are ready to merge it :)

Don't forget to review the code. In other way you'll be forced to delete the commit.

You can also use text method:

git checkout master
[COLOR="DeepSkyBlue"]# Check out your master branch[/COLOR]
git remote add TeamFun git://github.com/TeamFun/android_packages_apps_Settings.git
[COLOR="deepskyblue"]# Add a new remote named 'TeamFun'[/COLOR]
git fetch TeamFun
[COLOR="deepskyblue"]# Pull in all the commits from the 'cameronmcefee' remote[/COLOR]
git merge TeamFun/gingerbread
[COLOR="deepskyblue"]# Merge your master branch into the 'gingerbread' branch from the 'TeamFun' remote[/COLOR]
git push git@github.com:eagleeyetom/android_packages_apps_Settings.git master
[COLOR="deepskyblue"]# Push your newly-merged branch back to GitHub[/COLOR]

or

git checkout master
[COLOR="DeepSkyBlue"]# Check out your master branch[/COLOR]
$ curl http://github.com/octocat/Spoon-Knife/pull/25.patch | git am
[COLOR="deepskyblue"]# Grab the patch generated by a pull request and feed it into a new commit[/COLOR]
$ git push git@github.com:eagleeyetom/android_packages_apps_Settings.git master
[COLOR="deepskyblue"]# Push your newly-updated commit back to GitHub[/COLOR]

TIPS AND TRICKS

REVERT CHANGES

To discard all unstaged changes e.g. failed merge etc. type:

git checkout .
# to delete all changes

git checkout path/to/file

# to discard changes for a specific file

You can also use:

rm -rf ./

[COLOR="Cyan"]# deletes all of the files in the directory[/COLOR]

git reset --hard

[COLOR="cyan"]#This is going to restore the git to the previous state[/COLOR]

HOW TO REMOVE COMMITTED CHANGES?

To remove committed changes you have to revert the commit. But how to do that? It's your answer

git reset HEAD --hard

HEAD is the previous commit. To revert to previous state use HEAD~1, HEAD~2 etc. you can also use the code taken from git log.

GIT PATCH AND GIT APPLY

Now I want to make a patch file to e.g. send an e-mail with my commited changes.

First I need to find a changes made by a commit. To do this I need to know commit ID.

git log --oneline #This would show the commit ID's

Now pick the commit for example 22a95d1 and use git show to make a patch

git show 22a95d1 > patchname.patch

And I got patch, but how to apply it?

The answer is easy. Use git apply.

git apply patchname.patch
# --check checks if the patch can be applied

FORCE PUSH

Sometimes github doesn't want to cooperate - just like some people :D

You can force it by adding --force or -f

git push -f git@github.com:eagleeyetom/android_packages_apps_Settings.git master

n00b method to add changes after failed push.

Clone the repo and delete everything but .git directory. Then copy modified content, commit and push :P