我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
、