我正在配置一个 github web hook 来调用下面的页面:
github.php:
<?php
shell_exec('git pull');
?>
我有 chmod 777
文件,甚至还有 chmod +x
。当我从服务器调用 php github.php
时一切正常:
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 3 (delta 2), reused 3 (delta 2)
Unpacking objects: 100% (3/3), done.
From https://github.com/mynameise/Octo
afadfb8..1ad3b76 master -> origin/master
但是当我尝试使用 http 从外部世界联系该页面时,没有任何反应。我的日志文件中也没有错误。这是怎么回事?
最佳答案
这是因为脚本没有从 git 存储库根目录运行,您需要直接在 php 代码中指定正确的 git 存储库路径:
<?php
shell_exec('git --work-tree=/full/path/to/git/repo --git-dir=/full/path/to/git/repo/.git pull');
?>
注意:对于裸存储库,您 shell 仅传递 --git-dir
键值。
关于php - "git pull"外部世界不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21174191/