First Fork the repo.

To clone your fork to your local machine:
git clone

Add the main repo as your upstream (so you can incorporate their changes):
git remote add upstream

To update your fork from original repo:
git fetch upstream
git merge upstream/branchName

Git Submodules

Adding a submodule
git submodule add

For a special URL

git config submodule.DbConnector.url PRIVATE_URL

For developers to update

git submodule update --remote <submodule name>
To set/change the default branch for a submodule

git config -f .gitmodules submodule.<project>.branch <branch name>
If you make changes to the wrong branch:
git stash
git checkout <correctBranch>
git stash pop

When you are ready to commit:
git status (to see files you've changed)
git diff (to see what you've changed)
git add <file or directory>
git commit (add commit message)
git push (actually sends your code up to the server)

To make a new branch:
git branch <newname>
git checkout <branchName>

To delete a local branch:
git branch -D <branchName>

To delete a remote branch:
git push origin --delete <branchName>

To merge one branch into another:
git checkout dev
git merge localbranch
(make sure it works)
git push

To tag/branch a release:
git checkout master (use gitg or gitk or git log to get the last sha1 key for that release)
git tag sprintXX <sha1>
git push --tags
git branch progam_sprintXX
git checkout program_sprintXX
git push origin program_sprintXX

To release source:
git checkout master (gitg to get sha1)
git branch branchname <sha1>
git checkout branchname
tar -cvfz --exclude='submodule' sprintXX.tgz dir/

Import an upstream branch into your fork:
git checkout -b newbranch upstream/newbranch

Add a pull request to your local machine
git fetch origin refs/pull/PR_NUMBER/head:LOCAL_BRANCH

Checkout a different user's branch to test.
git remote add theirusername
git fetch theirusername
git checkout -b mynamefortheirbranch theirusername/theirbranch

Cherry-pick a bunch of commits from a branch into a new one.  This happens if you are dumb and commit two features to the same branch.
git branch newFeature <SHA1 key before goofy commits>
git checkout newFeature
git cherry newFeature borkedBranch | awk '{ print $2}' > commits
vim commits (remove commits you don't want in the new feature branch)
Then I created a new script to do the cherry-pick on this file:

while read LINE; do
  `git cherry-pick $LINE`;
You can execute the code like this:
./ < commits

Remove a deleted remote branch from you local list.
git branch --merged > /tmp/merged-branches
vim /tmp/merged-branches  <-- Remove any branches you don't want to delete (i.e. master, dev)
xargs git branch -d </tmp/merged-branches

Remove branches on origin that are not in remote.
git remote prune origin

Squash commits for an existing PR:
git rebase -i origin/<branch merging into (i.e. dev)>
Change commits you want squashed to `s` or `squash`.  They will squash up, so leave one as `pick` when you want to squash others into it.
pick 8fb98ef Commit 1
squash ba37cd8 Commit 2
squash 78ca893 Commit 3
Then force push your new history:
git push origin feature_branch -f