Fixing Capistrano 3 deployments after a repository change
I recently changed a repository url of a project. However, I found out that editing your project's capistrano repo_url isn't enough. This usually was easy with Capistrano 2.
set :deploy_via, :remote_cache
doesn't work anymore with Capistrano 3. shared/cached-copy
doesn't exist anymore as well and has been replaced with /data/appname/repo
. (replace /data/appname
with your actual deployment directory).
It was actually quite annoying since I can't find a decent way to fix the besides redoing the mirror (deleting /data/appname/repo?) or by manually updating the config. I went ahead with editing the config.
So, to get your instances updated...
vim /data/appname/repo/config
[core]
repositoryformatversion = 0
filemode = true
bare = true
[remote "origin"]
fetch = +refs/*:refs/*
mirror = true
url = git@github.com:username/oldrepo.git
to
[core]
repositoryformatversion = 0
filemode = true
bare = true
[remote "origin"]
fetch = +refs/*:refs/*
mirror = true
url = git@github.com:username/newrepo.git
Run cap deploy
then all will be fine again.
Cheers.
Follow me on Twitter as @jasontorres
Written by Jason Torres
Related protips
7 Responses

I just ran into this issue, thank you for documenting this!

Jesus christ thank you. 5 hours later. Much appreciated!

Or update it from from Capistrano itself:
namespace :git do
task :update_repo_url do
on roles(:all) do
within repo_path do
execute :git, 'remote', 'set-url', 'origin', fetch(:repo_url)
end
end
end
end

Great post, thanks for that.

This saved me today. Well done.

This saved me
Thank you!