4k1lja
Last Updated: March 20, 2016
·
6.204K
· jasontorres
3af261e4328c1610e1cd563d067f276b

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

Say Thanks
Respond

7 Responses
Add your response

18252
7ff6ba0b742c6066f7094de212e9efad

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

over 1 year ago ·
18339
8zma77ty normal

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

over 1 year ago ·
18820
F1a3945f946bb34d84f257534fb9d4e4

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
over 1 year ago ·
19829
None

Great post, thanks for that.

over 1 year ago ·
20785
None

This saved me today. Well done.

over 1 year ago ·
24563
None

This saved me

over 1 year ago ·
27431

Thank you!

over 1 year ago ·