尝试`git archive master`时,Capistrano部署失败

时间:2014-01-05 13:21:47

标签: ruby-on-rails capistrano

我想使用Capistrano部署我的rails项目,但在尝试cap production deploy:updating时失败。

这是错误消息。 (我替换了域名和项目名称。)

[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
 INFO [f71ac456] Running /usr/bin/env mkdir -p /tmp/exmaple/ on example.com
DEBUG [f71ac456] Command: /usr/bin/env mkdir -p /tmp/exmaple/
 INFO [f71ac456] Finished in 0.736 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/exmaple/git-ssh.sh 0.0%
 INFO Uploading /tmp/exmaple/git-ssh.sh 100.0%
 INFO [c1918686] Running /usr/bin/env chmod +x /tmp/exmaple/git-ssh.sh on example.com
DEBUG [c1918686] Command: /usr/bin/env chmod +x /tmp/exmaple/git-ssh.sh
 INFO [c1918686] Finished in 0.062 seconds with exit status 0 (successful).
DEBUG [905ddc4a] Running /usr/bin/env [ -f /var/www/example.com/repo/HEAD ] on example.com
DEBUG [905ddc4a] Command: [ -f /var/www/example.com/repo/HEAD ]
DEBUG [905ddc4a] Finished in 0.053 seconds with exit status 0 (successful).
 INFO The repository mirror is at /var/www/example.com/repo
DEBUG [e9c1eeda] Running /usr/bin/env if test ! -d /var/www/example.com/repo; then echo "Directory does not exist '/var/www/example.com/repo'" 1>&2; false; fi on example.com
DEBUG [e9c1eeda] Command: if test ! -d /var/www/example.com/repo; then echo "Directory does not exist '/var/www/example.com/repo'" 1>&2; false; fi
DEBUG [e9c1eeda] Finished in 0.053 seconds with exit status 0 (successful).
 INFO [9bd77dfe] Running /usr/bin/env git remote update on example.com
DEBUG [9bd77dfe] Command: cd /var/www/example.com/repo && /usr/bin/env git remote update
DEBUG [9bd77dfe]    Fetching origin
 INFO [9bd77dfe] Finished in 0.068 seconds with exit status 0 (successful).
DEBUG [4fe5034f] Running /usr/bin/env if test ! -d /var/www/example.com/repo; then echo "Directory does not exist '/var/www/example.com/repo'" 1>&2; false; fi on example.com
DEBUG [4fe5034f] Command: if test ! -d /var/www/example.com/repo; then echo "Directory does not exist '/var/www/example.com/repo'" 1>&2; false; fi
DEBUG [4fe5034f] Finished in 0.059 seconds with exit status 0 (successful).
 INFO [d75938a4] Running /usr/bin/env mkdir -p /var/www/example.com/releases/20140105125534 on example.com
DEBUG [d75938a4] Command: cd /var/www/example.com/repo && ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/exmaple/git-ssh.sh /usr/bin/env mkdir -p /var/www/example.com/releases/20140105125534 )
 INFO [d75938a4] Finished in 0.057 seconds with exit status 0 (successful).
 INFO [9f7ea103] Running /usr/bin/env git archive master | tar -x -C /var/www/example.com/releases/20140105125534 on example.com
DEBUG [9f7ea103] Command: cd /var/www/example.com/repo && ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/exmaple/git-ssh.sh /usr/bin/env git archive master | tar -x -C /var/www/example.com/releases/20140105125534 )
DEBUG [9f7ea103]    fatal: Not a valid object name

这是我的Capistrano设置文件production.rb

set :application, 'example'
set :repo_url, '~/git-repos/example.com.git'

set :deploy_to, '/var/www/example.com'
set :scm, :git
set :branch, 'master'

set :keep_releases, 5

namespace :deploy do

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
    end
  end

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
    end
  end

  after :finishing, 'deploy:cleanup'
end

我已登录远程服务器,cd /var/www/example.com/repogit archive master,然后收到同样的错误:fatal: Not a valid object name

我应该怎样解决这个问题?

2 个答案:

答案 0 :(得分:0)

手动执行git push origin master后,部署结束且没有错误。

首先git push必须手动完成。

答案 1 :(得分:0)

将您的 deploy.rb 中的分支设置为您的 repo 中存在的分支...可能是您拥有 main 而不是 master...