Capistrano和Git,毁了我的生命."无法解决存储库中[HEAD]的修订..."

ajh*_*406 5 git deployment ssh capistrano ruby-on-rails

我搜索了所有相关的Capistrano问题,但找不到任何东西,甚至在这里为我阐明了什么.

git version 1.6.4.2
Capistrano v2.5.10
Run Code Online (Sandbox Code Playgroud)

基本上,当我运行我的cap deploy.rb脚本时,它连接到服务器,开始执行deploy:update任务,然后在deploy:update_code任务中:

    *** [deploy:update_code] rolling back
  * executing "rm -rf /home/user_name/public_html/project_name/releases/20091223094358; true"
    servers: ["project_name.com"]
Run Code Online (Sandbox Code Playgroud)

它失败并出现以下错误:

/Library/Ruby/Gems/1.8/gems/capistrano-2.5.10/lib/capistrano/recipes/deploy/scm/git.rb:231:in `query_revision': Unable to resolve revision for 'master' on repository 'ssh://git@slice_ip:path_to_git_repository'. (RuntimeError)
Run Code Online (Sandbox Code Playgroud)

这是我的部署脚本,我尝试过包含和省略:

设置:分支'主'

我也只是认为我的存储库路径已经关闭,但我已经尝试了几乎所有的排列(绝对的,不是绝对的,.git后缀,没有后缀).在我指向的路径上肯定有一个简单的git存储库.

**我确实在一个片上托管了多个项目.其他项目也是一个rails项目,但正在运行SVN.Capistrano部署工作正常.

如果我无法弄明白这一点,任何指示正确的方向或任何想法将有助于减少我计划做的饮酒量.(路径/ IP混淆,不要破坏我兄弟!)

set :application, "project1"
set :user, "username"
set :repository,  "ssh://git@67.24.9.133/home/git/project1.git"
set :branch, "master" 

set :port, 696969

set :deploy_to, "/home/username/public_html/#{application}"

set :scm, :git

role :app, application                    
role :web, application                    
role :db,  application, :primary => true 

# deployment via remote client (workstation)
set :deploy_via, :copy 
set :runner, user

# mod_rails
namespace :deploy do
  desc "Restarting mod_rails with restart.txt"
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "touch #{current_path}/tmp/restart.txt"
  end

  [:start, :stop].each do |t|
    desc "#{t} task is a no-op with mod_rails"
    task t, :roles => :app do ; end
  end
end
Run Code Online (Sandbox Code Playgroud)

这是最相关的帖子(甚至非常相关),但我无法弄清楚他们说的修复是什么.我对git/capistrano配置很新.

https://capistrano.lighthouseapp.com/projects/8716/tickets/56-query_revision-unable-to-resolve-revision-for-head-on-repository

ajh*_*406 4

好吧,我似乎已经修好了。

基本上,由于我在远程服务器上有 2 个独立的存储库,我认为“git”用户失败了,因为我没有为 git 用户注册 ssh 密钥对。这就解释了为什么我的一个deploy.rb 脚本可以正常工作,而这个却不能。

在我在问题中发布的链接中,一位评论者指出了这个问题:

https://capistrano.lighthouseapp.com/projects/8716/tickets/56-query%5Frevision-unable-to-resolve-revision-for-head-on-repository

请注意,如果您在每个http://capistrano.lighthouseapp使用多个 github 密钥 ...并且您在运行的工作站上的 .ssh/config 中没有这些密钥和相应的条目,也会显示此错误部署自. 所以 ls-remote 在本地运行。当远程部署使用 git@github-project1:user/project1.git 时,有没有办法针对此请求引用 github.com 上的存储库

另外,请参阅以下链接了解更多详细信息,因为即使您不使用 github,整个 ssh 问题也将适用。

http://github.com/guides/multiple-github-accounts