I have my apache2 webserver directory as a Git directory, so when me and my team members (school project) make changes to our GitHub folder, it can easily be pulled by running 'git pull' in putty.
I want to make this automatic (using a WebHook) by having a "pull.php" file that has "<?php exec("git pull"); <?" inside it.
However, the user that shows up when I run whoami function in php is "www-data".
In order to allow www-data to run git pull without having to enter credentials (I tried setting up SSH and it refused to work), I need to allow them to store credentials.
This is problematic because unlike other users, www-data has no directory in /home/accountname to save its .gitconfig to.
How do I go about having "git credential.helper store" work for www-data?
I would also not mind having SSH, but I run into the same problem where the default directory to save the id_rsa file to says no permission/does not exist, so I would prefer the previous question to be answered.
EDIT: In the end it was a variety of problems. it was trying to pull using HTTPS because i cloned it using HTTPS. long story short, i ended up deleting the repo and recloning it with SSH and all of my problems went away. There were a lot of steps in between but anyone with a similar problem can just do that and skip the headache haha.
You have a similar issue in WordOps/WordOps #305
www-data user cannot write anything in
/var/wwwbecause this directory's owner isroot. So you can create the.gitconfigfile as root, and then change owner and permissions (following this recommendation) withchown www-data:www-data /var/www/.gitconfig chmod 644 /var/www/.gitconfig.Or you can change
/var/wwwdirectory owner (chown www-data /var/www) to allowwww-datato create files in this directory.
The OP ChristianWagner confirms that cloning the repository with SSH instead of HTTPS allows for the git pull to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With