Drupal development site code updates using GIT-Pull


Israel Office



Europe office


Drupal development site code updates using GIT-Pull
submitted by: Shai Weinstein

We started using GIT SCM for all the new development projects.
GIT's advantages are widely discussed elsewhere- it is fast, efficient, and is a DVCS.
The reason that is important is that it's much faster than SVN and the branching is so easy you don't think about it much as you develop (much less SVN merge drama :) )
One of my motivations (as the CPO in Linnovate - Chief Paranoid Officer) is not to open ssh for too much people in my production servers (not even to our developers!).
That was the motivation behind git-pull it provides a useful mechanism which lets developers easily update the code of a development site.
(right now this module can actually be used for both SVN and GIT code updates)

Setting up this module requires some Operating System configurations, the reason is file system permissions guidelines of a Drupal site (the user which runs the web server should not have access to change or create any PHP files).

This setup is based on Linux..

  • Protecting .git folder from 'prying eyes':
    The default .htaccess file of Drupal 6 doesn't include a protection for the .git folder.
    to protect it - simply add a rewrite rule after the RewriteEngine directive:

    RewriteEngine on
    RewriteRule "(^|/)." - [F]

    the above directives will protect every name with "." in the beginning.
    Drupal 7 already includes this protection.

  • configuring /etc/sudoers:
    allow the web server's user to run git pull command - (usually apache or www-data on Linux):

    www-data ALL=NOPASSWD: /usr/bin/git pull

  • edit git_pull.module file (TODO - move it to settings.php).
    change in lines 'aegir' to the user which have write access to the PHP code files and document root.
    $command = 'cd '. $root .'; sudo -H -u aegir git pull 2>&1';
  • enable module - and You will have new button in Drupal admin's menu - 'GIT PULL'.

Another module for managing a Drupal development site using GIT is gittyup.


Very cool.

I think there is a typo in $command = 'cd '. $root .'; sudo -H -u aegir git pull 2>&1';


no, that's "aegir" allright! :)

this worked at my site really good! thanks!

Add new comment


Welcome popup block