我正在尝试使用git-http-backend设置智能HTTP。我试图在网上关注如何做到这一点的大量文档/指南。我在Windows 7上运行的Apache 2.4在我的httpd.conf我有Git智能HTTP协议无法在推送时执行服务器端挂钩
SetEnv GIT_PROJECT_ROOT c:/repos
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ "c:/program files/git/mingw64/libexec/git-core/git-http-backend.exe/"
<LocationMatch "^/git/.*/git.*$">
Require all granted
</LocationMatch>
<Directory "c:/program files/git/mingw64/libexec/git-core/">
<Files "git-http-backend.exe">
Require all granted
</Files>
</Directory>
对于C:\repos
,我确信每个人都具有完全访问权限。我在我的用户帐户下运行httpd.exe,因此对服务器的请求应该在PATH上看到git 2.12.2。
在C:\repos
,我有一个名为foo.git
的裸回购。在回购里面我做git config http.receivepack true
。我能够用http://localhost/git/foo.git克隆得很好。 没有启用服务器端钩子,我能够推送一个提交就好了。
现在恼人的一部分 - 我创建一个更新挂钩,只是C:\repos\foo.git\hooks\update
包含以下内容:
#!/bin/bash
echo foo
exit 0
我尝试从本地回购推动,并得到
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 315 bytes | 315.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://localhost/git/foo.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'http://localhost/git/foo.git'
好了,我尝试用git协议推动同样的事情 - 我运行了git daemon --reuseaddr --base-path=C:\repos C:\repos
。然后我在foo.git
里放了一个git-daemon-export-ok
。我回到当地的回购协议,并推到git:///foo.git
:
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 315 bytes | 35.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: foo
To git:///foo.git
3b33593..6af841c master -> master
一切顺利。我推动文件协议 - file:///c/repos/foo.git
,这工作也没关系。
我试着在我的httpd.conf做
<Directory c:/>
Require all granted
</Directory>
,以确保它没有任何关系与访问问题。当然,我将它切换回Require all denied
。
基于详细的推送,似乎git-receive-pack无法在服务器端启动bash解释器,但我不知道为什么。同样,它是从我的用户帐户下运行的httpd.exe产生的,我可以手动执行git。再次,git可以在PATH上找到。我在这里错过了什么样的明显解决方案?