Writing a patch on a sandbox/dev install using a git branch
Go to the module you want to patch and do a:

git diff original_branch final_branch &gt; /path/to/file.patch


Test it by applying the patch to the initial module:

patch -p1 &lt; /path/to/file.patch


or

git apply --index /path/to/file.patch


More info:

http://linux.about.com/od/commands/l/blcmdl1_patch.htm

https://drupal.org/node/707484