Creating a patch with Git suitable for submitting to Drupal.org
Take the hash of a 'before' commit and the 'after' commit 'sha' hash and stay relative to the current directory and output a patch:
~/code/dgd7/drupal/sites/all/modules/views$ git diff --relative 5ac40a1 cb64d08 > 817748-views-book-hierarchy-sort-12.patch
If you've merely made the changes but not committed them you can use git diff > patch_name-1234-57.patch
or if you've staged but not committed you can use git diff --cached patch_name-1234-57.patch
.
Note: Now that Drupal is bending itself to the Git way, we no longer need --no-prefix because as git diff
outputs patches with a/ and b/ prefixes and git apply
expects them by default (though both can take a -p0 option), people not using git are expected to use patch -p1
which takes the a/ and b/ prefixes into account.