【问题标题】:Git push over HTTP not activating remote hooksGit通过HTTP推送未激活远程挂钩
【发布时间】:2011-05-21 07:32:48
【问题描述】:

在我的远程机器上,我已经初始化了一个裸 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 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

但是,远程机器上的 /tmp/githooks.log 是空的。但是,如果我在远程计算机上克隆存储库,则挂钩会成功调用。

git 钩子不能与 http-push 一起使用吗?

【问题讨论】:

标签: git webdav


【解决方案1】:

使用 Git protocols,您将启用不同的功能。
对于 HTTP,this thread 总结了问题:

这里的“问题”(这与 HTTP 协议的设计方式非常相似)是 它不是 git 在推送时更新远程端的存储库(它知道钩子),但网络服务器通过 WebDAV
而网络服务器对钩子一无所知。

也许当“智能”HTTP 协议得到实施时,这会得到改进(目前处于设计阶段,我认为是在设计协议之后)。

正如您所说,smart http 就是答案。

此功能被称为“智能”HTTP 与“哑”HTTP,因为它需要在服务器上安装 Git 二进制文件,而之前的 HTTP 传输咒语只需要一个简单的网络服务器。
它与客户进行真正的对话,而不是简单地推出数据。

【讨论】:

    猜你喜欢
    • 2014-02-23
    • 2013-07-22
    • 2011-01-27
    • 1970-01-01
    • 1970-01-01
    • 2017-06-08
    • 1970-01-01
    • 2019-04-01
    • 1970-01-01
    相关资源
    最近更新 更多