Git推送HTTP不激活远程钩子 [英] Git push over HTTP not activating remote hooks
问题描述
在我的远程盒子上,我初始化了一个裸露的git存储库。在hooks目录中,我使用以下脚本初始化了post-receive,post-update和update钩子:
# !/ bin / bash
echo $ 0 $ @>> /tmp/githooks.log
在我的本地框中,我已经克隆了存储库,添加了一个测试文件,提交并将更改推回到远程框。
$ git clone https:// remote / git / sandbox .git sandbox
$ cd sandbox
$ touch asdf
$ git add asdf
$ git commit -a
[master(root-commit)37505de] zxcv
0文件改变,0插入(+),0删除( - )
创建模式100644 asdf
$ git push origin master
获取远程主...
refs /
refs / heads /
refs / tags /
更新'refs / heads / master'
from 0000000000000000000000000000000000000000
to 37505de9c22b0aee84e0071190f4f58728770675
发送3个对象
完成
更新远程服务器信息
到https://remote/git/sandbox.git
* [new branch] master - > master
但是,远程计算机上的/tmp/githooks.log为空。但是,如果我在远程计算机上克隆存储库,则会成功调用钩子。
git钩子不能用于http-push吗?
与 Git协议 ,您将启用不同的功能。 这里的问题(这是非常重要的方式) HTTP协议的设计)是它不是通过WebDAV更新远程端的存储库(它知道挂钩),而是通过WebDAV / strong>。 也许这会在智能HTTP协议得到实施时得到改进(目前处于设计阶段,我想就是在设计协议后)。 正如您所评论的, 智能http 就是答案。 这个特性被称为智能HTTP vs哑HTTP,因为它需要Git二进制安装在服务器上,以前的HTTP传输咒语只需要一个简单的网络服务器。 On my remote box, I've initialized a bare git repository. In the hooks directory, I've initialized the post-receive, post-update and update hooks with the following script: On my local box, I've cloned the repository, added a test file, committed it and pushed the change back to the remote box. However, /tmp/githooks.log is empty on the remote machine. If, however, I clone the repository while on the remote machine, the hooks are successfully called. Do git hooks not work with http-push? With Git protocols, you will have different features enabled. The "problem" here (which is very much the way HTTP protocol was designed) is that it isn't git that updates repository on remote side on push (which knows about hooks), but web server via WebDAV. Perhaps that would get improved when "smart" HTTP protocol gets implemented (currently in the phase of design, I think just after designing protocol). As you commented, smart http would be the answer. This feature is referred to as "smart" HTTP vs "dumb" HTTP because it requires having the Git binary installed on the server, where the previous incantation of HTTP transfer required only a simple webserver.
这篇关于Git推送HTTP不激活远程钩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
对于HTTP,
Web服务器对钩子一无所知。
它与客户端有真正的对话,而不是只是愚蠢地推送数据。
#!/bin/bash
echo $0 $@ >> /tmp/githooks.log
$ git clone https://remote/git/sandbox.git sandbox
$ cd sandbox
$ touch asdf
$ git add asdf
$ git commit -a
[master (root-commit) 37505de] zxcv
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 asdf
$ git push origin master
Fetching remote heads...
refs/
refs/heads/
refs/tags/
updating 'refs/heads/master'
from 0000000000000000000000000000000000000000
to 37505de9c22b0aee84e0071190f4f58728770675
sending 3 objects
done
Updating remote server info
To https://remote/git/sandbox.git
* [new branch] master -> master
For HTTP, this thread summarizes the issue:
And web server knows nothing about hooks.
It has a real conversation with the client, rather than just dumbly pushing out data.