Gitolite推送错误 -> 远程:ENV GL_RC未设置

10

我试图将内容从工作站推送到服务器,但出现了错误。请查看以下命令和错误:

Administrator@ganesh ~/testing  
$ git push origin master  
Counting objects: 3, done.  
Writing objects: 100% (3/3), 241 bytes, done.  
Total 3 (delta 0), reused 0 (delta 0)  
remote: ENV GL_RC not set  
remote: BEGIN failed--compilation aborted at hooks/update line 20.  
remote: error: hook declined to update refs/heads/master  
To git@ganesh:repositories/testing  
 ! [remote rejected] master -> master (hook declined)  
error: failed to push some refs to 'git@ganesh:repositories/testing'  

看起来我需要设置环境变量GL_RC。是这样吗?

这里有人能告诉我问题可能是什么,以及如何解决吗?我正在Windows Server 2003上使用gitolite。


1
它以“remote:”为前缀,这意味着gitolite更新钩子会打印该错误。看起来在存储库中gitolite配置不正确。 - Jan Hudec
如何找到问题?我不是很清楚。我应该重新安装gitolite吗? - amar4kintu
4个回答

9
如文档ssh故障排除所示,这可能是在克隆过程中路径不正确导致的。
文档(以下某些部分仅适用于Gitolite V2)提到:

第二个错误

(即“您可以克隆存储库,但无法将更改推回(错误抱怨GL_RC环境变量未设置,并且钩子/更新以某种方式失败)

如果您使用git@server:repositories/reponame.git(假设默认设置为$REPO_BASE - 在Gitolite V3中,它始终是~/repositories)- 也就是说,您使用了完整的Unix路径
由于上面提到的“前缀”不是必需的,因此shell会找到repo并成功克隆。
但是当您推送时,gitolite的更新钩子会启动并因缺少其期望的某些环境变量而无法运行。

“easy-install”程序成功运行后出现的消息明确包括以下警告:
*Your* URL for cloning any repo on this server will be
        gitolite:reponame.git

    *Other* users you set up will have to use
        <user>@<server>:reponame.git
    However, if your server uses a non-standard ssh port, they should use
        ssh://<user>@<server>:<port>/reponame.git

在您的情况下,您必须使用以下命令克隆您的代码库:
git clone git@ganesh:repositories/testing.git

改为:

git@ganesh:testing.git

3
@VonC:感谢你的回答。你说得没错。但是当我尝试使用git clone git@ganesh:testing.git克隆存储库时,它会提示**'testing.git不是git存储库'**。我不确定问题出在哪里或者该如何纠正它。你能给我一些建议吗?谢谢。 - amar4kintu
@amar4kintu:只是为了确认一下,git clone git@ganesh:testing 不带最后的“.git”会返回什么? - VonC
1
@VonC:感谢您再次回复。它返回相同的错误:“testing”似乎不是git存储库。 - amar4kintu
@amar4kintu:首先,在处理ssh时,没有本地用户名:您的密钥可以引用任何您想要的用户。一个用户可以有多个密钥。这里唯一的“用户”是安装了gitolite的服务器端上的用户。其次,我真的建议您使用“from client”安装方法(https://github.com/sitaramc/gitolite/blob/pu/doc/1-INSTALL.mkd#_from_client_method_install_from_the_client_to_the_server),在此处记录(http://sitaramc.github.com/gitolite/doc/install-transcript.html):确保ssh密钥的先决条件得到尊重。 - VonC
@amar4kintu:不用谢,我很高兴你最终解决了问题 :) - VonC
显示剩余7条评论

2
这篇文章是关于ssh故障排除的,你可以在http://sitaramc.github.com/gitolite/doc/ssh-troubleshooting.html找到它(也可以在gitolite源代码库中找到)。现在这篇文章已经进行了全面的修订。我希望它能更加流畅,更易理解,包括特定的错误。此外,建议至少第一次阅读完整个文档。 Sitaram

SSH故障排除文档的链接现在为http://sitaramc.github.com/gitolite/sts.html。 - appas

2

刚刚也遇到了同样的错误。

正确的做法是使用 git clone gitolite:repo_name 命令来克隆代码库,使用git push gitolite:repo_name 来推送更改,而不是使用 git clone git@yourservername:repo_name


@simont:请注意,在代码格式化中,**加粗不起作用。(毕竟它可能是双指针间接引用或乘方,或者展示如何在Markdown中加粗内容...) - sarnold
@sarnold 我没有想到那个 - 已经注意到了。 - simont

2

请尝试:

ssh git@ganesh

你应该看到的是gitolite-shell而不是bash:
ssh git@localhost

PTY allocation request failed on channel 0 hello
id_rsa, the gitolite version here is 2.0.3-2 (Debian) the gitolite
config gives you the following access:
     R   W  gitolite-admin
    @R_ @W_ testing
Connection to localhost closed.

如果不是这样,那就意味着你绕过了gitolite-shell而使用bash。 可能的原因是,通过运行gl-setup your_pub_key.pub,你将你的密钥添加到/home/git/.ssh/authorized_keys文件的底部。

因此,这个密钥永远不会被使用,因为在顶部有其他密钥。所以,你只需要打开/home/git/.ssh/authorired_keys并将最近添加的gitolite密钥移动到文件的顶部。

将此记录移到文件顶部后,你应该能够使用: git clone git@ganesh:testing.git 而不是 git clone git@ganesh:repositories/testing.git 第二个会克隆仓库,但会导致错误,因为你是通过bash而不是gitolite-shell运行"git push"。


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