XiZi's Blog

Git Over Http: Service not enabled: 'receive-pack'

如果你使用了Git的git-http-backend 后台服务 (git push/pull/clone over http instead of ssh or git),并且没有配置客户端认证。你可以在push的时候遇到这个错误: The requested URL returned error: 403..,查看apache后台提示错误:Service not enabled: 'receive-pack'。 

解决方法如下:

 在git response 目录下执行下面的命令,以打开匿名情况下的http.receivepack服务。

git config --file config http.receivepack true

接着贴一下GitOverHttp的Apache2配置吧:在需要配置的虚拟主机之间加入如下配置:

 

# Set this to the root folder containing your Git repositories.
# 指定 Git 版本库的位置
SetEnv GIT_PROJECT_ROOT F:/Dropbox/GitRepo
# Set this to export all projects by default (by default,
# git will only publish those repositories that contain a
# file named “git-daemon-export-ok”
# 该目录下的所有版本库都可以透过 HTTP(S) 的方式存取
SetEnv GIT_HTTP_EXPORT_ALL

# Route specific URLS matching this regular expression to the git http server.
# 令 Apache 把 Git 相关 URL 导向给 Git 的 http 处理程序
AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$          "F:/Dropbox/GitRepo/$1"
AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ "F:/Dropbox/GitRepo/$1"
ScriptAliasMatch \
        "(?x)^/git/(.*/(HEAD | \
                        info/refs | \
                        objects/info/[^/]+ | \
                        git-(upload|receive)-pack))$" \
        "D:/Program Files (x86)/Git/libexec/git-core/git-http-backend.exe/$1"
						
<Directory "D:/PROGRA~1/Git/libexec/git-core/">
	Options Indexes FollowSymLinks
	AllowOverride AuthConfig
	order allow,deny
	allow from all
</Directory>
<Directory "F:/Dropbox/GitRepo">
	Options Indexes FollowSymLinks
	AllowOverride AuthConfig
	order allow,deny
	allow from all
</Directory>




Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee