Is there any way to clone or pull the HEAD version of a module in git repository?

For example, if I'm on Drupal 7, and the last branch of Views is 3, I would like to do:

drush git-clone views

to achieve something equivalent to:

cd sites/all/modules/
git clone --recursive --branch 7.x-3.x

Ideally, using drush git-clone views-3x should clone the 3.x branch explicitly.

Is this possible or am I dreaming? This would be really useful for developing.

up vote 10 down vote accepted
drush dl views-7.x-3.x --package-handler=git_drupalorg


True, if there are commits after the dev release was packaged, you will need to run git pull to advance to HEAD after checking out via drush dl. If there is no packaged dev release, and Drush checks out a stable release, then you need to run git checkout 7.x-3.x after drush dl.

There is no Drush command to do a verbatim git clone; part of the "value add" of drush dl is that it grabs published releases. If git clone is what you want, perhaps a short bash script would be your best solution. Something like this:


$ clonedev views 3

Example script:



DRUPAL=$(drush status "Drupal Version" --pipe | sed -e 's/\..*//')
if [ -n $DRUPAL ] ; then
  cd $(drush drupal-directory modules)

git clone --recursive --branch $DRUPAL.x-$VERSION.x$MODULE.git

Modify to suit.

  • I've just tried it, and it downloads the latest dev release, not HEAD. And if there is no dev release available, it downloads the latest recommended or supported release. – Pere Feb 20 '13 at 16:16
  • Okay, see updated answer. – greg_1_anderson Feb 20 '13 at 17:54

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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