GIT
Basic commands
Change username, e-mail
Globally
git config --global user.name
git config --global user.email
For a repo
git config user.name
git config user.email
Change remote origin
Check all branches and its tracking
git show remote origin
Change branch tracking
git branch branch_name -u <your_new_remote/branch_name>
Clone and pull
Rebase rolling commits above
git pull --rebase
Refresh
git fetch -p
Clean and reset branches
Delete untracked files and folders
git clean -fd
Make a local branch identical to a remote
one
git reset --hard origin/<branch_name>
Diff and merge
Diff
git diff <commit_id>
git difftool <commit_id>
Merge
git merge <branch_name>
git mergetool <branch_name>
Delete branches
To remove a local branch from your machine:
git branch -d the_local_branch
git branch -D the_local_branch
To remove a remote branch from the server:
git push origin :the_remote_branch
git push origin --delete the_remote_branch
Adding external repositories
git submodule add <repo.git> <local folder>
git submodule init
git submodule update
Configure remote branch tracking
git branch -u upstream/foo
Patches
Generate a patch from the last commit
git format-patch -1 HEAD
Apply a patch
patch -p1 < file.patch
Colours
git config --global color.ui auto

Git basics