git-http-backend在通过http

时间:2015-06-05 04:06:40

标签: git http backend

我正在我的服务器上创建git存储库。我的要求是我必须在服务器上创建多个git存储库,我必须使用用户名和密码来保护它们。

由于创建了多个git存储库,我将.htpasswd和.htaceess放在每个git存储库文件夹中以保护它们。

以下是我正在做的整个流程。

a)用git -bare创建了git存储库 b)在该文件夹中创建.htpasswd和.htaccess进行身份验证 c)我现在能够使用用户名和密码克隆该repo。

但是当我尝试从克隆的回购中推出时,它给我一个错误: 错误:无法访问URL http://192.168.1.2/projects/gitcreation/gitrepos/6/project6/,返回代码22 致命:git-http-push失败

任何帮助都将受到高度赞赏。

1 个答案:

答案 0 :(得分:0)

我最初建议删除对gitolite的推/拉调用(见下文),但OP希望保留直接调用。

Jiva怀疑git-http-backend未被推送(wouldn't work well indeed}检查for instance this configthis one

另一项检查是.gitconfig of the bare repohttp.receivepack

作为此thread illustrates,问题可能是凭证(密码不正确,或密码中包含特殊字符,错误解释)

原始答案。

不要依赖于.htaccess / .htpasswd每个git repo,最好在perl中调用 gitolite authorization layervery easy to install)基于Apache完成的身份验证,可以授予对repo的访问权限。

有关详情,请参阅“What is gitolite”。

请参阅我的httd.conf for example(忽略@xxx@,它们是模板占位符,稍后将被实际值替换)

<VirtualHost @FQN@:@PORT_HTTP_HGIT@>
    ServerName @FQN@
    ServerAlias @HOSTNAME@
    SetEnv GIT_PROJECT_ROOT @H@/repositories
    SetEnv GIT_HTTP_EXPORT_ALL
    SetEnv GITOLITE_HTTP_HOME @H@
    ScriptAlias /hgit/ @H@/sbin/gitolite-shell/
    SetEnv GIT_HTTP_BACKEND "@H@/usr/local/apps/git/libexec/git-core/git-http-backend"
    <Location /hgit>

此处,对于任何/hgit个网址(/projects为您),系统会调用/home/git/sbin/gitolite-shell
如果gitolite授予用户访问repo的权限,它将调用GIT_HTTP_BACKENDgit/libexec/git-core/git-http-backend所在的位置。

Gitolite允许您设置每个仓库many access rules,甚至每个分支或每个文件!