git, gitolite 错误推送
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10283947/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git, gitolite error push
提问by buffle
I just installed gitolite but when I push on the repository gitolite-admin I get an error:
我刚刚安装了 gitolite,但是当我推送存储库 gitolite-admin 时,出现错误:
git push
Counting objects: 9, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (7/7), 605 bytes, done.
Total 7 (delta 1), reused 0 (delta 0)
remote: Empty compile time value given to use lib at hooks/update line 6
remote: Use of uninitialized value in require at hooks/update line 7.
remote: Can't locate Gitolite/Hooks/Update.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at hooks/update line 7.
remote: BEGIN failed--compilation aborted at hooks/update line 7.
remote: error: hook declined to update refs/heads/master
To ssh://[email protected]/home/admin/repositories/gitolite-admin.git
! [remote rejected] master -> master (hook declined)
error: failed to push some refs to 'ssh://[email protected]/home/admin/repositories/gitolite-admin.git'
I don't know what I must do.
我不知道我必须做什么。
can you help me?
你能帮助我吗?
thanks
谢谢
采纳答案by roberthernandez
Before you start: The gitboxis the remote machine with git and gitolite installed. The gituser is the user that gitolite runs as on the gitbox.
开始之前:gitbox是安装了 git 和 gitolite 的远程机器。该git的用户是用户是gitolite作为运行在gitbox。
You can overcome this error by (1) generating a new key pair, (2) registering the public key on the gitbox, and (3) by ensuring that when you connect to the gitbox, that you always connect as the gituser using your new private key.
您可以通过 (1) 生成新的密钥对,(2) 在 gitbox 上注册公钥,以及 (3) 通过确保在连接到 gitbox 时始终以git用户身份使用您的新的私钥。
For the ninja, that's probably enough. For the rest, here's more detail:
对于忍者来说,这可能就足够了。其余的,这里有更多细节:
Step 1) Generate a new keypair
步骤 1) 生成新的密钥对
Most IDEs have the ability to create a new public/private keypair. Alternatively, if have access to a Linux machine you can generate your own using:
大多数 IDE 都能够创建新的公钥/私钥对。或者,如果可以访问 Linux 机器,您可以使用以下方法生成自己的机器:
ssh-keygen -t rsa -f john_git_rsa
The output will be a set of private (john_git_rsa) and public (john_git_rsa.pub) keys (aka the keypair). You'll need to copy the public key to the gitbox in the next step.
输出将是一组私有 ( john_git_rsa) 和公共 ( john_git_rsa.pub) 密钥(又名密钥对)。您需要在下一步中将公钥复制到 gitbox。
Step 2) Register new public key on gitbox
步骤 2) 在 gitbox 上注册新的公钥
You can find out how to use git to administer gitolite-admin with a quick search of Google. Briefly, the steps are: (1) clone the gitolite-admin repository; (2) add the new public key to the gitolite-admin/keydir/ directory; and (3) push the changes back to the gitolite-admin repository. The push triggers the gitbox to register any new keys in the keydir/ folder with the authorized users list of the gitbox's git user.
您可以通过快速搜索 Google 来了解如何使用 git 来管理 gitolite-admin。简单来说,步骤是:(1)克隆gitolite-admin仓库;(2) 将新的公钥添加到gitolite-admin/keydir/目录下;(3) 将更改推送回 gitolite-admin 存储库。推送会触发 gitbox 使用 gitbox 的 git 用户的授权用户列表在 keydir/ 文件夹中注册任何新密钥。
Your gitbox is now ready to accept new connections from those authenticating as the gituser, using the john_git_rsaprivate key.
您的 gitbox 现在已准备好接受来自那些使用john_git_rsa私钥进行身份验证的git用户的新连接。
Step 3) Ensure your connections to the gitbox use the git user and new private key
步骤 3) 确保您与 gitbox 的连接使用 git 用户和新的私钥
If you're connecting to the gitbox using terminal, edit/create the ~/.ssh/config file to include an alias that preconfigures your connection to the gitbox. The alias looks like:
如果您使用终端连接到 gitbox,请编辑/创建 ~/.ssh/config 文件以包含预配置与 gitbox 连接的别名。别名看起来像:
Host gitbox
User git
Hostname yourgitbox.com
Port 22
IdentityFile ~/.ssh/john_git_rsa
Now, executing commands like >git clone gitbox:reponame.git, or >git push gitbox:reponame.git ensures you're using the git user and appropriate private key. Without this alias, you'd have to do something like >git clone ssh://[email protected]:22/reponame.git and find out the ssh switch for specifying the private key to use – not pretty. (Note: If you connect without using this alias, your default ssh key will be used and you will receive permission errors.)
现在,执行诸如 >git clone gitbox:reponame.git 或 >git push gitbox:reponame.git 之类的命令可确保您使用的是 git 用户和适当的私钥。如果没有这个别名,您必须执行类似 >git clone ssh://[email protected]:22/reponame.git 之类的操作,然后找出用于指定要使用的私钥的 ssh 开关——这并不漂亮。(注意:如果您在不使用此别名的情况下进行连接,将使用您的默认 ssh 密钥,并且您将收到权限错误。)
ORif you use an IDE (NetBeans, Eclipse, etc.):
或者,如果您使用 IDE(NetBeans、Eclipse 等):
You need to find your IDE's SSH settings and set them to use the new private key you created (john_git_rsa) instead of the default keys it generated during its install. You also need to ensure the URI of your push repository is set to something like:
您需要找到 IDE 的 SSH 设置并将它们设置为使用您创建的新私钥 (john_git_rsa) 而不是它在安装过程中生成的默认密钥。您还需要确保推送存储库的 URI 设置为类似以下内容:
ssh://[email protected]:22/reponame.git
that the username is set to git, and the password field is empty. This ensures that when you're connecting to the gitbox that your IDE will supply the private key you just setup and the git user.
用户名设置为git,密码字段为空。这确保当您连接到 gitbox 时,您的 IDE 将提供您刚刚设置的私钥和 git 用户。
Now your pushes should work.
现在你的推送应该有效。
回答by CharlesB
Googling for "Empty compile time value given to use lib at hooks/update", first result is in Gitolite FAQ:
谷歌搜索“在钩子/更新时使用lib的空编译时间值”,第一个结果在Gitolite常见问题解答中:
You're bypassing gitolite. You cloned the repo using the full path (i.e., including the repositories/ prefix), either directly on the server, or via ssh but with a key that gives you shell access.
Solution: same as for the previous bullet.
你绕过了gitolite。您直接在服务器上或通过 ssh 使用完整路径(即,包括存储库/前缀)克隆了存储库,但使用一个可以让您访问 shell 的密钥。
解决方案:与上一个项目符号相同。
Previous bullet:
上一个要点:
Use a different keypair for gitolite. There's a slightly longer discussion in the setup page. Also see why bypassing causes a problemand both the documents in sshfor background.
对 gitolite 使用不同的密钥对。设置页面中有一个稍长的讨论。另请参阅为什么绕过会导致问题以及ssh 中的两个文档作为背景。
回答by Danil Ovsyannikov
It's very good comment from #roberthernandez, but i want to add some emphasises to this.
My big broblem with installing gitolite (and push'ing of course) were with checking, that '~/bin' directory is in PATH environment variable. We need use export PATH=$PATH:~/bin
for set this setting. Without this option i think, gitolite can not exec his processes and has problems with PUSHing from you. Plus, after that you can use gilotile setup ...
instead bin/gitolite setup ...
.
#roberthernandez 的评论非常好,但我想为此添加一些强调。我在安装 gitolite(当然还有 push'ing)时遇到的大问题是检查“~/bin”目录是否在 PATH 环境变量中。我们需要使用export PATH=$PATH:~/bin
来设置这个设置。如果没有这个选项,我认为 gitolite 无法执行他的进程,并且在从你那里推送时会出现问题。另外,在那之后你可以gilotile setup ...
改用bin/gitolite setup ...
.