[Samsung Galaxy S Blaze 4G] thomas.raines:
To sync your changes, for the first time github says to do this:

git init
git add <FILE NAME>
git commit -m "Initial commit"
git remote add <remote name> <url>
git pull <remote> <branch>
git push <remote> <branch>

Sometimes that works... sometimes it doesn't

Real way:

git remote add LZkernel [URL]https://github.com/TeamFahQ/msm8660-common_lz_kernel.git[/URL]
git add -A
git commit -m "I made some changes"
git push LZkernel HEAD:jellybean
git pull <remote> <branch>
git push <remote> HEAD:<branch>

Example

git pull LZkernel HEAD:jellybean
git push LZkernel HEAD:jellybean

sync upstream

git remote add <NAME> <URL>
git pull <NAME> <BRANCH>
git push <remote> HEAD:<branch>

Example

git remote add Cyanogenmod https://github.com/CyanogenMod/android_kernel_samsung_msm8660-common.git
git pull Cyanogenmod jellybean
git push LZkernel HEAD:jellybean

git remote add TeamFahQ https://github.com/TeamFahQ/msm8660-common_lz_kernel.git
git pull TeamFahQ jellybean
git push Thomas-is-a-BAMF HEAD:jellybean

How bout git fetch?

Well, I'm still new to using fetch, but here's that basics

Now let's say you want to add some spicey goodness froma particular commit. So you go on github.com and

find that commit. It is represented but a code, i.e. cac585fcd52fa5ed2e0fbbc4d2b292575ccc10a2 (or the short/nice number cac585fcd5)

You can find this by going to that particular repo, clicking on "commits" at the top and then finding the commit you want to pick.

Here's how we are going to do it:

git remote add <NAME> <URL>
git fetch <NAME> <BRANCH> (or you can use git fetch --all)

Now that we have to commits, it time to choose our commit and pick it.

You will now type:

git cherry-pick <COMMIT NUMBER>

But it's not all that easy..normally. Let's say we have conflicts. Usually the output will tell you what files conflict. You can either use:

git mergetool and fix them one bye one (provided you have a comparing program like meld), or you can open the files and look at them in your text editor.

I woul;d have to say, it is much easier with something like meld or beyond compare. This allows you to see your current file the lines to be merged and

the upstream files. But the best rule I use is this:

everything from:

<<<<<<<< HEAD
to
=============

is what you currently have.

Everything below

=============
to
cherry-pick <COMMIT DESCRIPTION>

is what will be inserted. I typically delete everything between

<<<<<<<< HEAD
to
============

as well as the pointers

<<<<<<<< HEAD
to
============
cherry-pick <COMMIT DESCRIPTION>

Leaving the new code, and it usually works out...lol

Now the we have our conflicts fixed we now must commit and continue. Simply type:

git add -A
git cherry-pick --continue

This will bring up the commit in nano (terminal). At this point, if you have text to add, you can added it, press ctrl+x, etc...

Another useful tool. Say you looked at the upstream of which you forked your repo from and see they have updated a few thing, and you want/need to add those changes. You can chery-pick, or merge with upstream:

git merge <NAME> <BRANCH>

fix conflicts

git add -A (The commit will come up in terminal)
git push <NAME> HEAD:<BRANCH>

Now, let's say you made A LOT, or a few changes. You built and found out they didn't work like how you wanted. Or you accidentally made changes and wanted to revert back to you original source. Here's what you can do:

git log

This will give you all the current commit numbers. Note the commit you want to revert back to and copy the commit number only (type q to exit). Now you can type:

git reset --hard <COMMIT NUMBER>

Now you repo is back to it's pre oops state as I like to call it...lol

According to git, this will undo ALL your changes and restore your repo back to that particular commits state; however, I have found that if you added a completely new file, it does not remove it. To check, type:

git status

This will tell you any files that are untracked and files that you have un-commited changes. I frequently use this command to track where I am with a project,and I also run this command before I commit to make sure I don't miss noting or commiting all my changes.

Now let's say you made changes and pushed them, but found later that you made a mistake. So you quickly git reset then try to push. However, you get a fast forward fail broke, holy crap I don't know what to do error... Well, there is a fix for that:

git push -f <NAME> <BRANCH>

You WILL be removing ALL changes the occurred before the particular commit you reset. So be sure you don't reset too far back...

You can now build and test your changes. After you have verified everything is a go, you can now push your changes to your repo.

This is a living document. I would actually like to see this stickied for quicker, easier access. As I learn new things, I will add on to this tutorial. Enjoy!