One important workflow to attempt to standardize is the method in which an organization rolls out updates to its production webservers. If you’re making heavy use of Git (and GitHub) in your development environment, it only makes sense to bundle your updates into patch files that can safely be applied and rolled back by someone with no working knowledge of the source code.
To create a patch file out of a Git commit, you’ll first want to retrieve the commit ID that your patch will retrieve data from. The git log command below retrieves information regarding the last 3 commits made:
$ git log -3 commit b29d8f2a0e6ad5595330f62f60b978fbc5696bcb Author: Sully Syed <firstname.lastname@example.org> Date: Fri May 13 15:41:05 2011 -0400 The Feed Importer module will hook into Drupal's cron scheduler script and retrieve new featured articles automatically. commit 65abfeeea27311effb21a547af99b3427126601f Author: Sully Syed <email@example.com> Date: Fri May 13 15:36:01 2011 -0400 Add the Google logo image to the footer directory. commit 33764e5d9ccd0222ad3d38cc1e77eb8242fb120d Author: Sully Syed <firstname.lastname@example.org> Date: Wed May 11 15:45:41 2011 -0400 Fixed the typo that would have made Skynet sentient. $ git format-patch --help
The git format-patch command allows us to select a range of commit IDs to bundle into a patch. For our example, the range will consist of begin and end with the same commit ID to limit the patch to the one commit:
$ git format-patch -M -C b29d8f2a0e6ad5595330f62f60b978fbc5696bcb~1..b29d8f2a0e6ad5595330f62f60b978fbc5696bcb 0001-The-Feed-Importer-module-will-hook-into-Drupal-s-cron-.patch
The patch file created takes the name 0001-The-Feed-Importer-module-will-hook-into-the-Drupal-s-cron-.patch, which can then be e-mailed or sent by other means to the production staff who will apply it.