Git post-receive未运行

3
我在这里搜索了几个问题,但没有找到答案,因此我会根据我的具体情况提问。
真的很简单的post-receive钩子,只需要将其弯曲到Redmine上,以强制Redmine在提交时更新存储库的视图。(为了调试起见,我还echo “Post Receive Hook Go”)
设置: Bare Repo /git/repos/test.git
$ cd ~/
$ git clone file:///git/repos/test.git
$ cd test/
$ vim somefile_gets_updated
$ git commit -a -m 'Tackling bug #1, include the bug number so Redmine will pick it up and associate it'
$ git push origin master

这会正常提交和推送,但是post-receive钩子不触发。 如果我执行以下命令: $ curl http://localhost:3000/sys/fetch_changesets?key=cGdcUaRr8u4Rr4zXzXhr并刷新我的Redmine问题页面,它就能够工作了,太好了! 如果在推送后我执行以下操作:
$ ./.git/hooks/post-receive

I get:

$ Post Receive Hook Go

太好了,它可以工作!

所以我知道curl是可行的,即使post-receive也可以工作,但是Git却没有触发它。

这就是钩子。

 $ cd .git/hooks
 $ ls -l | grep post-receive
 $ -rwxr-xr-x  1 bobbydown  staff   109 Dec 22 03:42 post-receive

我就是不明白为什么 git 没有运行这个钩子...

1个回答

1

在存储库接收推送提交后,后置接收钩子将触发。

在您的情况下,您的钩子应该在裸存储库中,而不是克隆存储库中。


@John - 你所说的裸仓库是什么意思? - Dariux
@Darius.V 通常情况下(就像这个问题中),裸仓库是服务端的,它没有工作树。请查看 http://git-scm.com/book/en/v2/Git-on-the-Server-Getting-Git-on-a-Server - John Flatness
1
我找到了post-receive无法运行的问题所在。这是因为我的服务器就像客户端一样,而bitbucket或类似的服务器则是服务端。由于我无法访问bitbucket的Linux服务器,因此无法运行post-receive。但是我使用了post-merge,它可以放在我的服务器上,一旦接收到文件,它们就会合并,从而触发钩子。Post-merge属于客户端类别。 - Dariux

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接