【发布时间】: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 一起使用吗?
【问题讨论】:
-
嗯。对此的明显答案是 Smart HTTP (git http-backend)。 progit.org/2010/03/04/smart-http.html