接收后,请求 php 脚本,拉取 git 存储库

发布于 2024-12-25 15:04:28 字数 672 浏览 4 评论 0原文

我的网络服务器上有一个 PHP 脚本 git.php,只有几行,其中一行使用 shell_exec() 运行

'git pull ssh://[email protected]/repo.git' 

(请注意,您无法推送到网络服务器,这已被禁用并且无法启用。) 如果您访问 example.com/git.php,这一切都可以正常工作。脚本运行并且存储库得到更新。 (存储库位于另一个不相关的服务器上)

我想做的是使用我的 post-receive 挂钩从我的 git 服务器更新我的 web 服务器上的 git 存储库。我正在使用 ssh 进行连接,因此钩子应该(并且确实有效,我已经测试过)有效,并且我非常确定不存在权限问题。

我的问题是如何编写“接收后”脚本?

我尝试了一些方法,但没有成功,我的脚本目前只有 1 行长,看起来像这样,

curl -d "action=post-receive&log=1" http://example.com/git.php

但这什么也没做。 :(

有谁可以帮助我吗?或者建议我可以做得更好吗? 提前致谢。

I have a PHP script git.php on my web-server with only a few lines, one of the lines uses shell_exec() to run a

'git pull ssh://[email protected]/repo.git' 

(Please note, you cannot push to the webserver, this is disabled and cannot be enabled. )
This all works fine if you go to example.com/git.php. The script runs and the repo gets updated. (the repo is on another unrelated server)

What I am trying to do is use my post-receive hook to update my git repo on my web server from my git server. I am using ssh to connect, so hooks should (and do work, i have tested that) work, and am pretty sure there are no permissions problems.

My question is how do I write the 'post-receive' script?

I have tried a few things with no luck, my script is currently 1 line long and looks something like this

curl -d "action=post-receive&log=1" http://example.com/git.php

but this does nothing. :(

Is there anyone who can help me? Or suggest anything that I could do better?
Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文