Here's a cheatsheet of a few git commands I find useful. Nothing revolutionary, just the absolute basics:

Client commands

Setup

 git config --global user.name "Firstname Lastname"
 git config --global user.email "[email protected]"

Clone a new remote repository

 git clone [email protected]: /full/path/to/repository/on/server.git local_directory

Clone a new remote repository WITHOUT any files

 git clone --no-checkout [email protected]: /path/on/server.git local_directory

Create a new local branch

 git branch -b new_local_branch_name

Delete an existing local branch

 git branch -d local_branch_name

Delete local branch and lose all unmerged changes

 git branch -D local_branch_name

Create new local branch to track a remote branch

 git checkout --track -b new_local_branch_name remotes/origin/remote_branch_name

Switch to a branch

 git checkout branchname

Push existing local branch to remote

 git checkout branchname
 git push branchname new_remote_branch_name

Delete branch from remote (you have to discard local commits manually)

 git push branchname :remote_branch_name

List all local branches

 git branch -l

List all remote branches

 git branch -r

List all branches

 git branch -a

Switch to a remote branch

 git checkout remotes/origin/branchname

Diff with last committed version:

 git diff ./path/to/file.c

Overwrite with last committed version:

 git checkout ./path/to/file.c

Add file to index (must be committed later)

 git add ./path/to/new/file.c

Remove file from index (must be committed later)

 git rm ./path/to/old/file.c

Check status of repository

 git status

Commit changes

 git commit

 # Commit with commit message inline
 git commit -m "commit message"

Push committed changes from local to remote

 git push origin <branchname>

Discard local commits and resync with remote

 git reset HEAD ./path/to/file.c

Graph branches

 git log --graph --all
 git log --graph --format=oneline --all

Server commands

Create a git 'remote' repository

 sudo su - gituser
 cd git/root/dir
 mkdir repo.git
 cd repo.git
 git --bare init
 git config core.sharedrepository 1
 git config receive.denyNonFastforwards true
 find objects -type d -exec chmod 02770 {} \;

Mirror a bare remote repository to another remote repository

 sudo su - gituser
 cd git/root/dir
 git clone --mirror user@remote-repo

Periodically update the mirrored repository

 git fetch --all [-q]

Check if a repository is 'bare' or not

 git rev-parse --is-bare-repository