Why does not work git commit in shell_exec()?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
151 views
You need to run the Gita from a php script. Other commands work fine, namely the commit does nothing and nothing appears.

That is, if they do:
$git_branches = shell_exec('git add ../'.$_GET["FILE"]);

Then everything is fine.

If you do:
$git_branches = shell_exec("git commit-m '".$_GET["COMMIT_TITLE"]."'");

You get the void.

To obtain at least some information, he is the right location and so on, I tried this option:
$git_branches = shell_exec("cd ".$_SERVER["DOCUMENT_ROOT"]." && ls-la && git commit-m '".$_GET["COMMIT_TITLE"]."'"); pre($git_branches);

Displays a list of files and directories from the root of the project, all as needed. Therefore there and trying to commit again, as I required. But the commit command is not working.
by | 151 views

3 Answers

0 like 0 dislike
For debugging you should use the following scheme:

$git_branches = exec('git push origin master:'.$_GET["REMOTE"].' 2>&1', $stdin, $stderr);


That is, change shell_exec to exec, and add "2>&1"; Then we can see the error.

Itself commit command did not work because the config was not correctly specified by the user. And because the user have not enough rights. Appointed him as the owner of the folder .git. The problem was solved
by
0 like 0 dislike
$git_branches = shell_exec('git commit-m "'.$_GET["COMMIT_TITLE"].'"');

So try it. Perhaps git's sensitive to type the quotes. But this is not accurate.
by
0 like 0 dislike
$str = 'git -c user.email=email-c user.name="login" commit-m "message"'; exec($str,$stdin,$stderr);
by
110,608 questions
257,187 answers
0 comments
40,796 users