Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/238.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在纯PHP中签出git存储库_Php_Git_Git Checkout - Fatal编程技术网

在纯PHP中签出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代码从应用

我需要使用纯PHP进行git签出。 我已经用HTTP和SASL尝试过这个()了,但是我没有真正起作用。 然后我看了一下GLIP(),但它似乎没有这样的功能。 基本上我需要

-复制/克隆远程git存储库

-将主分支文件“解压缩”到指定目录中

PHPGIT的主要问题是,它不支持您在提交中可以做的所有可能的更改。仅新文件,不移动文件。而且它也无法提取文件

/编辑: git未安装,我也无法安装git,您可以试用

Git Streamwrapper for PHP是一个PHP库,允许PHP代码从应用程序中与一个或多个Git存储库交互。该库包括一个Git存储库抽象(可用于以编程方式访问Git存储库)和一个流包装器(可连接到PHP流基础设施中),以允许开发人员直接对Git存储库中的文件使用文件和目录访问函数。该库提供了访问Git存储库状态信息的方法,例如日志、当前存储库状态或提交信息


它需要在机器上安装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;
    }
  }
?>