Capistrano deploy fails after I changed the reposi

2019-03-07 20:06发布

I have a simple deployment via capistrano from a Git repository. At first I was deploying form GitHub, everything worked just fine. But then I moved my repository to BitBucket and now I'm getting

fatal: Could not parse object '9cfb...'.

The problem goes away once I change

set :deploy_via, :remote_cache

to

set :deploy_via, :copy

but that doesn't fix the problem, it only bypasses it. Is there any way I can tell capistrano to just drop the old cache?

10条回答
SAY GOODBYE
2楼-- · 2019-03-07 21:04

You need to change git origin in your /shared/cached-copy folder

cd /var/www/your-project/production/shared/cached-copy
git remote remove origin
git remote add origin git@bitbucket.org:/origin.git

try cap production deploy

查看更多
做个烂人
3楼-- · 2019-03-07 21:04

Depends on your version Capistrano 3 is different from it's older ancestors:

Read my original answer here and how to fix similar issues Capistrano error when change repository using git

查看更多
Juvenile、少年°
4楼-- · 2019-03-07 21:05

The most simple way is just changing the repo url to the new one in .git/config in the shared/cached-copy directory on the webserver. Then you can do a normal deploy as usual.

查看更多
放我归山
5楼-- · 2019-03-07 21:11

Here's the Capistrano 3 version of what this answer talks about. It might be tedious to do what the answer suggests on each server.

So drop this in deploy.rb and then run cap <environment> deploy:fix_repo_origin

namespace :deploy do
  desc 'Fix repo origin, for use when changing git repo URLs'
  task :fix_repo_origin do
    on roles(:web) do
      within repo_path do
        execute(:git, "remote set-url origin #{repo_url}")
      end
    end
  end
end
查看更多
登录 后发表回答