Git CheatSheet

The most commonly used git commands are:
add Add file contents to the index
bisect Find by binary search the change that introduced a bug
branch List, create, or delete branches
checkout Checkout a branch or paths to the working tree
clone Clone a repository into a new directory
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
fetch Download objects and refs from another repository
grep Print lines matching a pattern
init Create an empty git repository or reinitialize an existing one
log Show commit logs
merge Join two or more development histories together
mv Move or rename a file, a directory, or a symlink
pull Fetch from and merge with another repository or a local branch
push Update remote refs along with associated objects
rebase Forward-port local commits to the updated upstream head
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
show Show various types of objects
status Show the working tree status
tag Create, list, delete or verify a tag object signed with GPG

List Branches
-----------------
git branch
git branch -r
Create New Branch and check it out
-----------------------------------
git checkout -b new_branch_name
Merge Branch into master
-----------------------------
1. git checkout master
2. git merge new_branch_name
Git push amster or branch to remote
-----------------------------------
git push (for master)
git push origin branch_name (for branch)
Delete branch from local and remote
-----------------------------------
git branch -d new_branch_name (from local)
git push origin :plugin_branch (from remote)
git pull master and remote branches
------------------------------------
git pull (master)
git pull origin remote_branch (remote branch)
Forked branch pull from origin/master
-------------------------------
git fetch upstream
git merge upstream/master
Push branch to remote
------------------------
git push -u origin plugin_branch
----------------------------------
This tells git to push changes from your plugin branch to the
plugin branch on the origin repository. If origin does not
have a plugin branch, it is created on the fly. The -u tells
git that you want to be able to easily push and pull changes
to that branch in the future.
Updates another repository
----------------------------
git fetch origin
git checkout --track origin/plugin_branch
The first command updates another repository with the changes
from the remote repository. The second command creates a
local branch named plugin_branch that matches the origin/plugin_branch
and tells git that this repo now wants to be able to
easily push and pull from the branch on GitHub. Bob can now
play with the code, commit his own changes and git push them
back up to the GitHub repository.

.gitignore file per project
.git/info/exclude per repo
http://gitready.com/beginner/2009/01/19/ignoring-files.html
ignore specific file that "is" tracked
I define the following aliases in my .gitconfig file:
[alias]
ignore = update-index --assume-unchanged
unignore = update-index --no-assume-unchanged
That should do exactly what you want: running git ignore
some-file will treat the file as unchanged no matter what
you do to it, until you run git unignore some-file.
http://stackoverflow.com/questions/5011390/git-ignoring-a-file-which-is-version-controlled
How to view untracked files and clean them out
git clean -ndX
Explanation:
git help clean
git-clean - Remove untracked files from the working tree
-n, --dry-run - Don't actually remove anything, just show
what would be done.
-d - Remove untracked directories in addition to untracked files.
-X - Remove only files ignored by git.
Note: This solution will not show ignored files that have
already been "cleaned."