PHP Script to pull changes from GIT Repository

Here is a PHP script, that pulls the latest code from Git Repository to your website.

&1", $r2);

echo "
";

foreach ($r2 as $line) {
	echo $line . "\n";
}

unset($r2);

echo "\n\n";
echo "------------------------------------------------------";
echo "\ngit status\n";
echo "------------------------------------------------------";
echo "\n\n";

$result = exec("git status 2>&1", $r2);

echo "
";

foreach ($r2 as $line) {
        echo $line . "\n";
}

https://gist.github.com/serverok/7efc12fcd75aac21309dbe234d9030f6

Upload the file to your web server as git-pull.php, access it with URL

https://yourdomain/git-pull.php?pw=YOUR_PASSWORD_HERE

For this script to work, your web server should work as the user that owns the files. If your webserver runs as www-data, you need to chown the files as www-data.

Example

chown -R www-data:www-data /path/to/doc/root/

See git

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *