I have a GIT repo and i'm using PHP script to pull from master branch and update files on server. It's really simple solution just to test it out. I wanted to add a webhook on github to send callback after successful push so i could pull from this repo.
Script runs both ways
- from command line
- from HTTP request
The difference is that when i run it from HTTP it doesn't pull new changes, just displays that it is up to date and doesn't do anything even if i'm 100% sure that there are new changes in repo. Output comes from GIT command so i'm sure it works and apache has proper rights to run that script file and commands which are used inside it.
When i run it via command line (through the same script or just clean git command) everything's fine, script pulls new changes and display standard GIT output.
PHP code:
echo "Pulling changes from master branch...\n";
$result = shell_exec('cd /var/git-test && git reset --hard HEAD && git pull');
if($result !== null){
echo $result;
}else{
echo $result;
echo "Error in Git pull comand";
}
How can i fix that?