【问题标题】:nameofrepo.git does not appear to be a git repositorynameofrepo.git 似乎不是 git 存储库
【发布时间】:2012-03-27 19:09:33
【问题描述】:

我正在尝试在自己的服务器上设置 git 并使用 capistrano 将我的项目推送到那里。

它仍然说

致命:'/home/gitolite/repositories/iminrails.git' 似乎没有 成为一个 git 仓库 但我可以在服务器上的目录存储库中看到 iminrails.git。 所以我尝试了不同的过程如何将我的 repo 推送到服务器上,但我仍然收到此错误。

ofer@debianruby:/var/www/iminrails$ scp -r /tmp/iminrails.git gitolite@example.com:/home/gitolite/repositories/
Enter passphrase for key '/home/ofer/.ssh/id_rsa':
bad command: scp -r -t -- /home/gitolite/repositories/
lost connection
ofer@debianruby:/var/www/iminrails$ git push origin master:refs/heads/master
Enter passphrase for key '/home/ofer/.ssh/id_rsa':
fatal: '/home/gitolite/repositories/iminrails.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

【问题讨论】:

  • 您的第一个命令甚至在您尝试推送之前就失败了。这应该在推送错误之前修复。
  • 尝试使用ssh 访问服务器并使用git init 创建存储库,以确认您拥有这些权限。

标签: git capistrano ssh-keys gitolite


【解决方案1】:

当您使用 gitolite 帐户使用 ssh 时,您将使用 ssh 配置来使用 forced command
Gitolite and ssh

如果你查看 authorized_keys 文件,你会看到这样的条目(我当然剪掉了结尾;它们很长):

command="[path]/gl-auth-command sitaram",[more options] ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA18S2t...
command="[path]/gl-auth-command usertwo",[more options] ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEArXtCT...

首先,它找出该文件中的哪些公钥与传入的登录名匹配。那是加密的东西,我不会涉及它。
一旦找到匹配项,它将运行该行给出的命令;例如,如果我登录,它将运行 [path]/gl-auth-command sitaram
所以首先要注意的是,这样的用户没有得到“shell访问”,这很好!

然而,在运行命令之前,sshd 会设置一个名为 SSH_ORIGINAL_COMMAND 的环境变量,其中包含您的工作站发出的实际 git 命令。如果您在授权密钥文件中没有 command= 部分,则该命令将运行。

这个想法很简单:

  • 没有交互式外壳访问
  • 仅 git 命令(因此您的 scp 命令不是 git 命令),它会被拒绝。

如果您需要将现有的本地 Git 存储库复制到远程 Gitolite 服务器,请参阅“moving pre-existing repos into gitolite

让 gitolite 将其创建为全新的 repo,如“adding users and repos”部分所述。

cd 到您工作站上的克隆。
确保所有分支都是正确的,并且没有额外的东西,“临时”分支等存在

现在运行这两个命令

git push --all git@server:reponame
git push --tags git@server:reponame

【讨论】:

    猜你喜欢
    • 2021-07-28
    • 2017-01-26
    • 2013-08-26
    • 1970-01-01
    • 2011-11-11
    • 2015-07-01
    • 2015-12-30
    • 2020-09-14
    • 2013-03-04
    相关资源
    最近更新 更多