Drupal development site code updates using GIT-Pull

You are here

Contact

Israel Office

+972-52-838-7222

+972-52-430-5252

Europe office

+33-695-805-004

28.12.2010
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.
    line:
    <?php
    ...
    $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.

Comments

Very cool.

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

Amitaibu

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

this worked at my site really good! thanks!

Add new comment

blogs