+
95
-

回答

使用exec函数,并且在服务器上安装了git命令:

<?php
// GitHub仓库的URL
$repositoryUrl = 'https://github.com/username/repository.git';

// 本地目录,将克隆的仓库放在这里
$localDirectory = '/path/to/local/directory';

// 执行git clone命令
$command = "git clone {$repositoryUrl} {$localDirectory}";
exec($command, $output, $returnCode);

// 检查命令是否执行成功
if ($returnCode === 0) {
    echo "克隆成功!";
    print_r($output);
} else {
    echo "克隆失败!";
    print_r($output);
}
?>

网友回复

我知道答案,我要回答