Skip to content

Instantly share code, notes, and snippets.

@sab99r
Last active November 17, 2021 10:26
Show Gist options
  • Save sab99r/bf1f38601af86345e1f2a7dab76e3e43 to your computer and use it in GitHub Desktop.
Save sab99r/bf1f38601af86345e1f2a7dab76e3e43 to your computer and use it in GitHub Desktop.
PHP shell_exec Github Webhook Git Pull
```code
if($_POST['payload']) {
echo shell_exec('cd /var/www/html/RepoFolder/ && git reset --hard HEAD && git pull https://[email protected]/username/RepoName.git 2>&1');
}
```
```code
//Find the Executing user and give permission
echo shell_exec('whoami');
eg. apache
//Give write permission to apache
sudo chown apache:apache -R RepoFolder
//Then give permission to apache for git
sudo chown -R apache:apache "$(git rev-parse --show-toplevel)/.git"
//source : https://stackoverflow.com/questions/18779442/error-while-pull-from-git-insufficient-permission-for-adding-an-object-to-repo
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment