I'm working with a Sandbox/Dev hosted VM with Drupal 7 and Commons 3. I want to write and perhaps contribute a patch. Having the site under local version control with git, I create a new branch write and test the code.

However, I'm at a loss how to create the patch file between the two branches (master and writing-patch).

Do I switch back the master? How do I compare two branches and properly put that into a patch file with the intention of sharing with a module maintainer? I'd like to do this properly and put as little work on the maintainer as possible.

1 Answer 1


Go to the module you want to patch and do a:

git diff original_branch final_branch > /path/to/file.patch

Test it by applying the patch to the initial module:

patch -p1 < /path/to/file.patch


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

More info:




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.