Git

Unstaged changes
git diff > out.patch

Staged changes
git diff --cached > out.patch

All changes
git diff HEAD > out.patch