Here are all the commands, starting from creating a new copy of a drupal repository and up to creating the patch to be published in the issue queue, the examples are for drupal core but the same may apply to contrib modules and themes too.
Get the code
git clone --branch 8.x http://git.drupal.org/project/drupal.git
Create a branch
git checkout -b branchnme
git checkout -b 766458-seven-rtl-112
Add untracked (new) files
git add path/to/file
git add themes/seven/ie7.css
git commit -a -m "commit message"
git commit -a -m "issue 766458-seven-rtl add ie7.css"
git fetch origin
Make your code apply to the latest version of the code
git rebase origin/8.x
git diff origin/8.x > patchname.patch
git diff origin/8.x > 766458-seven-rtl-112.patch
Or, if you want your patch to include author attributions (some credit for you) you should use:
git format-patch origin/[branchname] --stdout > [project_name]-[short-description]-[issue-number]-[comment-number].patch