在纯PHP中签出git存储库
我需要使用纯PHP进行git签出。 我已经用HTTP和SASL尝试过这个()了,但是我没有真正起作用。 然后我看了一下GLIP(),但它似乎没有这样的功能。 基本上我需要 -复制/克隆远程git存储库 -将主分支文件“解压缩”到指定目录中 PHPGIT的主要问题是,它不支持您在提交中可以做的所有可能的更改。仅新文件,不移动文件。而且它也无法提取文件 /编辑: git未安装,我也无法安装git,您可以试用在纯PHP中签出git存储库,php,git,git-checkout,Php,Git,Git Checkout,我需要使用纯PHP进行git签出。 我已经用HTTP和SASL尝试过这个()了,但是我没有真正起作用。 然后我看了一下GLIP(),但它似乎没有这样的功能。 基本上我需要 -复制/克隆远程git存储库 -将主分支文件“解压缩”到指定目录中 PHPGIT的主要问题是,它不支持您在提交中可以做的所有可能的更改。仅新文件,不移动文件。而且它也无法提取文件 /编辑: git未安装,我也无法安装git,您可以试用 Git Streamwrapper for PHP是一个PHP库,允许PHP代码从应用
它需要在机器上安装Git,并且在本文中是beta版。
< P>我开发了一个很好的PHP库来操作Git存储库,您应该考虑: 看起来像这样:$repository = new Gitonomy\Git\Repository('/path/to/repository');
$master = $repository->getReferences()->getBranch('master');
$author = $master->getCommit()->getAuthorName();
echo "Last modification on master made by ".$author;
很抱歉,我忘了提及它,但-git未安装,我无法安装它(共享Web空间):(我也有同样的困难,有人建议我使用FTPloy,对我来说还不够好,但也许值得一看。这是一个几乎相同的问题。这不也需要在系统上安装git
?@Alexandre Salume我曾经尝试过你的库,但无法使其运行。这个想法集中在n在本地操作我的存储库。假设我在wamp www文件夹中有一个php应用程序,上面初始化了git。是否可以使用你的库来操作该存储库,而不是使用BitBucket或Github作为源路径?如果你安装了git,那就疯狂吧
<?php
/**
* This function handles the pull / init / clone of a git repo
*
* @param $git_url
* Example of git clone url git://github.com/someuser/somerepo.git
*
* @return bool true
*/
public static function pullOrCloneRepo($git_url) {
if (!isset($git_url)) {
return false;
}
// validate contains git://github.com/
if (strpos($git_url, 'git://github.com/') !== FALSE) {
// create a directory and change permissions
$uri = 'public://somedir'; // change this if not in drupal
//check the dir
$file_path = drupal_realpath($uri); // change this if not in drupal
if (isset($file_path)) {
$first_dir = getcwd();
// change dir to the new path
$new_dir = chdir($file_path);
// Git init
$git_init = shell_exec('git init');
// Git clone
$git_clone = shell_exec('git clone '. $git_url);
// Git pull
$git_pull = shell_exec('git pull');
// change dir back
$change_dir_back = chdir($first_dir);
return true;
}
}
else {
return false;
}
}
?>