【问题标题】:Capistrano and Git, Ruining my life. "Unable to resolve revision for [HEAD] on repository ..."Capistrano 和 Git,毁了我的生活。 “无法解决存储库上 [HEAD] 的修订版......”
【发布时间】:2010-12-29 10:33:02
【问题描述】:

我搜索了所有相关的 Capistrano 问题,但找不到任何可以解释的内容。

git version 1.6.4.2
Capistrano v2.5.10

基本上,当我运行我的 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"]

它失败并出现以下错误:

/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)

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

设置:分支'主'

我也只是认为我的存储库路径已关闭,但我已经尝试了几乎所有排列(绝对的,不是绝对的,.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

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

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

【问题讨论】:

    标签: ruby-on-rails git deployment ssh capistrano


    【解决方案1】:

    好的,我似乎已经修复了它。

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

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

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

    请注意,如果出现此错误,也会显示 您正在使用多个 github 密钥 http://capistrano.lighthouseapp.... 而你没有这些钥匙和一个 您的相应条目 .ssh/config 在您所在的工作站上 从运行部署。所以 ls-remote 在本地运行。有没有 引用存储库的方法 github.com 对此请求,而 远程部署使用 git@github-project1:user/project1.git

    此外,有关更多详细信息,请参阅以下链接,因为即使您不使用 github,整个 ssh 问题也会适用。

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

    【讨论】:

      【解决方案2】:

      您的工作站和服务器都必须能够访问指定地址的存储库,否则您可能必须将 :local_repository 设置为从工作站访问它的方式,并将 :repository 设置为服务器应该访问的方式它。

      【讨论】:

      • 谢谢!我不知道你可以设置这两个变量,但它有效!
      【解决方案3】:

      对我来说,使用 Git 进行 Capistrano 部署似乎仅在设置 set :copy_cache, true 时才有效

      【讨论】:

        【解决方案4】:

        我只在 git 中使用过 capistrano 一次,但从未在存储库定义中使用或见过 ssh:// 的使用。

        尝试改用set :repository, "git@67.24.9.133/home/git/project1.git"

        【讨论】:

          【解决方案5】:

          确保您正在部署的分支存在。

          set :branch, "upgrade-to-2013.4.3"
          

          不等于

          set :branch, "upgrade-to-2013.3.4"
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2016-10-06
            • 2011-07-15
            • 1970-01-01
            • 1970-01-01
            • 2010-12-10
            相关资源
            最近更新 更多