Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pulling from Git by PHP and Console

Tags:

git

php

I have a repository for project which is on Bitbucket. I clone the repo to my local PC to work on it. Then I push back to Bitbucket, and then I connect with putty to my server and call

git pull

And pull the changes to the live server. I never push from my server. Everything works fine like this, but its not very convenient to connect through putty to server in order to pull. I made small script "git_pull_script.sh" in where is something like:

git reset --hard
git clean -f
git pull
chown -f -R tdadmin *
...

Nothing problematic there. If I run the script on server

bash /home/tdadmin/git_pull_script.sh

Everything goes well and does what I need. Just to clarify, git_pull_script has set owner and group tdadmin.

Now in order to make it simpler for me, I wrote this tiny php script.

<?php
exec('bash /home/tdadmin/git_pull_script.sh', $output);
print_r($output);

which I think should do the work. So I could simply call http://tddomain.com/pullscript.php

Unfortunately that does not work. What did I do wrong?

like image 620
Tomas Avatar asked Jul 16 '26 13:07

Tomas


1 Answers

The problem was in the file system rights. Even though have changed all permissions, ".git" repository folder stayed with root owner and group. Once I changed that, everything works just fine

like image 127
Tomas Avatar answered Jul 19 '26 03:07

Tomas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!