Tuesday, 9 October 2018

'commit' changes on webserver to Github repo using PHP not working

I'm trying to write a little PHP script that can spot all the changes to a local git repo on my web server and push them up to my (private) Github repo. Pushing and pulling from the Github repo using Atom works perfectly, pushing changes to the web server using a webhook works perfectly, pushing and pulling updates on the web server via the command line works perfectly, my problem is trying to commit and push updates on the web server to my Github repo using PHP. How do you do this?

If I have to change, add or even delete an entire template on the server manually I can commit those changes and push them up to Github using the command line like this no problem:

git add --all
git commit -m "from server"
git push -u origin master

But when I try to do this using a PHP script it never works and I get no error message (I even try with pauses):

$output = `git add --all`;
echo $output;
sleep(1);

$output = `git commit -m "from server"`;
echo $output;
sleep(3);

$output = `git push -u origin master`;
echo $output;
sleep(3);

If I run something simple like 'git --version', 'git config --list' or 'git status' it works perfectly from these scripts, so I'm at a loss.



from 'commit' changes on webserver to Github repo using PHP not working

No comments:

Post a Comment