Hello,
I am trying to execute a git commit command through php's shell_exec function, but it just doesn't do anything: nothing is output, the apache error log does not record an error, and if i paste the exact command in the cli then git does commit to the repository. I know this is not a privilege or permissions error since the repository belongs to the web server, and the file permissions are set to 777 (not that it matters). In addition, I am able to run the git checkout and git add commands, but only git commit fails (yet).
My code:
//stage files and then do the following
$command = "git commit -m 'I have modified a file'
shell_exec($command);
header('location: index.php');
If anyone has any ideas, type away!
PS: I believe this is an error pertinent to php, not git, hence my post in this section. I apologise if this ends up being more relevant to git.
Thank you,
Jawad.
Shell_exec not working with git commit
Moderator: General Moderators
Re: Shell_exec not working with git commit
Try
Code: Select all
$command = "git commit -m 'I have modified a file ' 2>&1";
echo shell_exec($command);
exit();There are 10 types of people in this world, those who understand binary and those who don't
Re: Shell_exec not working with git commit
What does the '2>&1' do? I tried echoing without it, and it was blank, but with it the shell_exec command tells me that the commit_editmsg file does not belong to the webserver (permissions always screw me up somehow). So that's why only the commit command was affected. Great, it works now!
Thanks,
Jawad.
Thanks,
Jawad.
Re: Shell_exec not working with git commit
There are 10 types of people in this world, those who understand binary and those who don't