Branching

Listing Branches

git branch
List all local branches.
git branch -r
List all local and remote branches.

Creating Branches

git branch new-branch
Create a new branch named new-branch, based on current branch.
git branch new-branch rev
Create a new branch named new-branch, based on revision specified by tree-ish rev.
git branch --track new-branch remote/remote-branch
Create a new tracking branch named new-branch, referencing, and pushing/pulling from, the branch named remote-branch on remote repository named remote.

Checking Out Branches/Revisions

git checkout branch
Switch to branch named branch. This updates the working tree to reflect the state of the branch named branch, and sets HEAD to ".git/refs/heads/branch".
git checkout rev
Switch to revision specified by tree-ish rev, without explicitly branching. Running "git checkout -b new-branch" will create a branch from the checked out version.

Simultaneous Creating and Switching Branches

git checkout -b new-branch
Create a new branch named new-branch, referencing the current branch, and check it out.
git checkout -b new-branch rev
Create a new branch named new-branch based on the tree-ish rev, update the working tree to reflect its state, and check it out (switch to it).

Deleting Branches

git branch -d branch
Delete the local branch named branch (fails if branch is not reachable from the current branch).
git branch -D branch
Force delete of the local branch named branch (works even if branch is not reachable from the current branch).
git branch -d -r remote/branch
Delete a "local remote" branch, i.e. a local tracking branch.
git push remote :heads/branch
Delete a branch named branch from a remote repository.