【发布时间】:2011-12-19 14:09:46
【问题描述】:
git add . 和git commit -m 之类的 git 命令如何使用 php 执行?
它适用于为维护学术项目创建集中存储库设施的项目。
exec() 似乎不起作用。
<?php
$path = "/var/www/repos/$_POST[project]";
$a='';
chdir($path);
exec("git add .");
exec("git commit -m'message'");
echo "<h3 align = center> Succesfully commited all the files.</h3>";
?>
【问题讨论】:
-
使用像php-git这样的库
-
exec应该可以正常工作,只要 PHP 脚本有权更新您的存储库。尝试使用system(),看看返回值是什么。 -
是否可以通过修改给出的代码来做到这一点?
-
已解决...问题在于 .git 的所有权,而不是 www-data