Easy Drupal 7 upgrade using Git patch file

Code everywhere

Updating Drupal 7 can be a challenging task. As a developer, using a version control system, like Git, helps me keep my sanity and also leverage it by creating and applying the patches rather than manually removing/adding files. This greatly helps especially if you're managing multiple Drupal 7 sites. 

Drupal 7 patch files

Download one of the patch files below to update your Drupal 7 core from one version to the next.

Alternatively, you can download the patch file below to upgrade your Drupal 7 core from the last security update to the latest.

Note: Files are gzipped, gunzip the file before use.

gunzip drupal-[version]-[version].patch.gz

Applying the patch using Git

  1. Check your current Drupal 7 version, download and unzip the appropriate patch file above.
  2. Using terminal, change to your Drupal 7 root directory
    cd ~/drupal-root
  3. Create a new branch for the update
    git checkout -b update/core-7.xx
  4. Check the patch to see if it applies without problems against your Drupal 7 installation
    git apply --check ~/path-to/drupal-[version]-[version].patch
  5. If there are changes to the default.settings.php file, change the directory permissions
    chmod 755 sites/default
  6. If you don't see any errors, go ahead and apply the patch
    git am --signoff < ~/path-to/drupal-[version]-[version].patch
  7. Once the update is complete, merge the update branch back into your master branch and push to the repository
    git checkout master
    git merge update/core-7.xx
    git push

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.