I need a PHP script to perform git pull however I am not naive enough to give it permissions on git. I've wrapped git pull in a script which www-data has permissions for, but I'm not sure how to give the script permissions on git itself:$ sudo tail -n1 /etc/sudoerswww-data ALL=(ALL) NOPASSWD: /home/php-scripts/git-pull$ cat /home/php-scripts/git-pull#!/bin/bash/usr/bin/git pull$ ls -la /home | grep php-scriptsdrwxr-xr-x  2 ubuntu ubuntu 4096 Sep  3 09:26 php-scripts$ ls -la /home/php-scripts/git-pull-rwxrwxr-x 1 ubuntu ubuntu 30 Sep  3 08:44 /home/php-scripts/git-pull$ cat /var/www/public_html/git-wrapper.php<?php$output = array();$value = 0;exec(/home/php-scripts/git-pull, $output, $value);echo <pre>;  echo Return Value: {$value}\n;foreach ( $output as $o) {    echo $o.\n;}?>Note that /var/www/public_html/ is in fact a git repository. I often perform git pull in that directory from the CLI. However, when I call this script in a web browser I see that the files were not updated via git pull and the following is output to the browser:Return Value: 1This is on Ubuntu Server 12.04 with Git 1.7.9.5. The remote repository is on the same server.
Allow www-data to perform specific commands
permissions;sudo;php;git
Your script runs under www-data:www-data I suppose. You have to run the git pull with a user that have a write permission on your cloned repository. You have configured sudo, but you don't call it anywhere which doesn't make much sense (not saying you need to do that at all). Verify under what user you are running and then switch to appropriate one if needed and adjust permissions on your cloned repository accordingly.