Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.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 如何从我的Github webhook中提取?_Php_Git_Github - Fatal编程技术网

Php 如何从我的Github webhook中提取?

Php 如何从我的Github webhook中提取?,php,git,github,Php,Git,Github,我正在尝试正确设置我的webhook。现在我有一个githook.php文件,其中包含以下函数: function gitPull() { $cmd ='cd /public_html/ethanzh; git pull -u origin master git@github.com:ethanzh/NumberGame_JS.git 2>&1;'; $str = shell_exec($cmd); if(strpos($str, 'error') !=

我正在尝试正确设置我的webhook。现在我有一个githook.php文件,其中包含以下函数:

function gitPull()
{
    $cmd ='cd /public_html/ethanzh; git pull -u origin master git@github.com:ethanzh/NumberGame_JS.git 2>&1;';

    $str = shell_exec($cmd);

    if(strpos($str, 'error') !== false)
        throw new Exception("Shell error: \n" . $str);

    return $str;
}
当我从Github网站检查我的webhook时,我看到以下错误:

fatal: 'master' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
现在,我的回购协议中没有任何分支机构,所有东西都被直接推到了“主”分支机构(我是唯一一个从事这项工作的人)

我认为我的问题与回购协议的实际底线有关。我能做些什么来解决这个问题


谢谢

首先,不要使用
-u
。虽然它是公开的,但它相对来说是Git内部的。它不像
push-u

-u --更新头部正常

默认情况下,git fetch拒绝更新与当前分支对应的头。此标志将禁用检查。这 纯用于git pull与git通信的内部使用 取回,除非你正在实现你自己的瓷器,否则你不是 我应该用它

其次,没有理由在最后一个参数中指定存储库URI。您位于Git存储库中,因此已经定义了
origin
(除非您指定了另一个远程服务器)。您应该对以下内容感到满意:

git pull origin master
如果需要更多详细信息,请参阅