Last Updated: February 25, 2016
· keyboardcowboy

Drupal: Features + Drush + Git Aliases to Boost Productivity

If you are using the Features module to export your Drupal site configuration, Drush, and Git as your VCS, try these aliases out to save a ton of time and boost your productivity.

  1. Create a Feature to encapsulate your site's configuration. In this example we'll call it mysite_config

  2. Add a configuration parameter in the git repo for your site:

    git config project.config mysite_config

  3. Add these git aliases to your global config to mimic drush shortcuts for feature-update, feature-export and feature-revert (you will need to edit the file directly):

Each is one line

fe = "!sh -c '[ -n $(git config project.config) ] && [ $# = 1 ] && drush -y fe $(git config project.config) $1 || echo \"Usage: git fe <features-component>\" >&2 && exit 1' -"

fr = "!sh -c '[ -n $(git config project.config) ] && drush -y fr $(git config project.config) || echo \"Set the configuration feature: git config project.config <feature-name>\" >&2 && exit 1' -"

fu = "!sh -c '[ -n $(git config project.config) ] && drush -y fu $(git config project.config) && git status || echo \"Set the configuration feature: git config project.config <feature-name>\" >&2 && exit 1' -"

Now, to update your feature, instead of typing drush fu mysite_config you can simply type git fu

Use git fe to export a new component to your feature and git fr to revert the db overrides.

These aliases also asserts the -y flag to skip through drush's prompts.

Say Thanks
Filed Under