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?
I solved this with the following in
deploy.rb
:It makes deploys a little slower, so it's worth removing once you're comfortable that all your deploy targets have caught up.
Capistrano 2 and below
SSH to your server and update the repo in
./shared/cached-copy/.git/config
of the deployment folder, or just remove the./shared/cached-copy
Capistrano 3 and above
SSH to your server and update the repo in
./repo/config
of the deployment folder.Check Fixing Capistrano 3 deployments after a repository change
If you need to do a lot of repo's you might want to add a task for it.
For capistrano 3 you add this task in your deploy.rb
And then run it once for every stage:
Capistrano 2.X
Delete and re-clone the repo using the new address:
Modify your
config/deploy.rb
to use the new repo:Deploy again:
Capistrano 3.X
$deploy_to/repo
directoryconfig/deploy.rb
(same as 2.X)cap deploy
I gotta say I’m not sure, since I haven’t been able to test this but this should work:
Since it wipes every release (cache) from the server.
Apparently you will also need to remove
shared/cached-copy
, because this doesn’t seem to be cleaned by the Capistrano call above according to the comment below.For Capistrano 3.0+
Change the repository URL in your config/deploy.rb
Change the repository URL in the your_project/repo/config file on the server.