git,gitolite错误推送 [英] git, gitolite error push

查看:719
本文介绍了git,gitolite错误推送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了gitolite,但是当我推送仓库gitolite-admin时,出现错误:

  git push 
计数对象:9,完成。
使用多达2个线程的增量压缩。
压缩对象:100%(6/6),完成。
写入对象:100%(7/7),605字节,完成。
总计7(增量1),重用0(增量0)
remote:为在钩子/更新行中使用lib给出的空编译时间值
remote:在require中使用未初始化的值at钩子/更新行7.
remote:无法在@INC中找到Gitolite / Hooks / Update.pm(@INC包含:/ 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。)在挂钩/更新第7行。
remote:BEGIN失败 - 编译在钩子/更新行7中断。
remote:错误:hook拒绝更新refs / heads / master
到ssh:// admin @ 192.168.0.26 / home / admin / repositories / gitolite-admin.git
! [remote rejected] master - > master(钩子拒绝)
错误:未能将某些参考推送到'ssh://admin@192.168.0.26/home/admin/repositories/gitolite-admin.git'



我不知道我必须做什么。



你能帮我吗?



感谢

解决方案

开始之前: gitbox 是安装了git和gitolite的远程机器。 git 用户是gitolite在gitbox上运行的用户。



您可以通过以下方式克服此错误:(1)生成一个新的密钥对,(2)在gitbox上注册公钥,以及(3)确保当你连接到gitbox时,你总是以 git 用户使用你的新私钥连接。



对于忍者来说,这可能就够了。其余部分详细介绍如下:

步骤1)生成一个新的密钥对

<大多数IDE都可以创建一个新的公钥/私钥对。或者,如果可以访问Linux机器,则可以使用以下命令生成自己的文件:

  ssh-keygen -t rsa -f john_git_rsa $输出将是一组私人( john_git_rsa )和公共( 



john_git_rsa.pub )键(又称密钥对)。您需要在下一步中将公钥复制到gitbox。


步骤2)在gitbox上注册新的公钥

你可以找到如何使用git通过快速搜索Google来管理gitolite-admin。简而言之,这些步骤是:(1)克隆gitolite-admin存储库; (2)将新的公钥添加到gitolite-admin / keydir /目录; (3)将更改推回到gitolite-admin存储库。推送触发gitbox注册keydir /文件夹中的任何新密钥与gitbox的git用户的授权用户列表。



你的gitbox现在准备好接受新的连接从那些认证为 git 用户,使用 john_git_rsa 私钥。



步骤3)确保您与gitbox的连接使用git用户和新的私钥



如果您使用终端连接到gitbox,请编辑/创建〜/ .ssh / config文件以包含一个别名,以便将您的连接预配置到gitbox。别名如下所示:

 主机gitbox 
用户git
主机名yourgitbox.com
端口22
IdentityFile〜/ .ssh / john_git_rsa

现在,执行像git clone gitbox :reponame.git或> git push gitbox:reponame.git确保您使用的是git用户和适当的私钥。如果没有这个别名,你必须做一些事情,比如> git clone ssh://git@yourgitbox.com:22 / reponame.git,并找出用于指定要使用的私钥的ssh开关 - 不够美观。

>或:如果您使用IDE(NetBeans,Eclipse等):



您需要找到您的IDE的SSH设置并将其设置为使用新的您创建的私钥(john_git_rsa),而不是它在安装期间生成的默认密钥。您还需要确保您的推送库的URI设置为如下所示:

  ssh://git@yourgitbox.com :22 / reponame.git 

用户名设置为 git ,并且密码字段为空。这确保了当你连接到gitbox时,你的IDE将提供你刚刚设置的私钥和git用户。



现在你的推送应该可以工作。 p>

I just installed gitolite but when I push on the repository gitolite-admin I get an error:

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://admin@192.168.0.26/home/admin/repositories/gitolite-admin.git
! [remote rejected] master -> master (hook declined)
error: failed to push some refs to   'ssh://admin@192.168.0.26/home/admin/repositories/gitolite-admin.git'

I don't know what I must do.

can you help me?

thanks

解决方案

Before you start: The gitbox is the remote machine with git and gitolite installed. The git user is the user that gitolite runs as on the 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 git user using your new private key.

For the ninja, that’s probably enough. For the rest, here’s more detail:

Step 1) Generate a new keypair

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:

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.

Step 2) Register new public key on 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.

Your gitbox is now ready to accept new connections from those authenticating as the git user, using the john_git_rsa private key.

Step 3) Ensure your connections to the gitbox use the git user and new private key

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:

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://git@yourgitbox.com: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.)

OR if you use an IDE (NetBeans, Eclipse, etc.):

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:

ssh://git@yourgitbox.com: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.

Now your pushes should work.

这篇关于git,gitolite错误推送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆