php system调用git 无output输出,并且返回128

发布于 / bug飞 / 0条评论 / Tags: git,php / 6 次浏览

我de需求是php调用git,返回当前git最新的commit id,代码如下:


<?php
$last_line = system('git  -C /www/wwwroot/pythons/python_book_gen log -1 --pretty=format:"%H"', $retval);
echo $retval;
echo "hello:$last_line";
?>

但是无输出,退出值 $retval=128,说明无权限,解决方式如下,bash运行:

git config --system --add safe.directory '*' # For all users and all repositories

    评论区(暂无评论)