Skip to content

Instantly share code, notes, and snippets.

@corny
Created November 14, 2013 01:31
Show Gist options
  • Star 25 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save corny/7459729 to your computer and use it in GitHub Desktop.
Save corny/7459729 to your computer and use it in GitHub Desktop.
Capistrano 3 with Git Submodules
# Save this file as lib/capistrano/tasks/git.cap
namespace :git do
desc 'Copy repo to releases'
task create_release: :'git:update' do
on roles(:all) do
with fetch(:git_environmental_variables) do
within repo_path do
execute :git, :clone, '-b', fetch(:branch), '--recursive', '.', release_path
end
end
end
end
end
@florentdestremau
Copy link

@liviucmg thanks i added your script directly in my deploy.rb and it works perfectly !

@dkarter
Copy link

dkarter commented May 4, 2015

@arthurbryant
Copy link

Thank you. After deployed I found I 'cd' to the directory of submodule and found that 'git branch' point to no branch. So I have to add another task to force it checkout to master branch. Any ideas?

 desc 'Checkout master'
  task :checkout_master do
      on roles(:app) do |host|
          within current_path do
              execute "cd #{app_path}/current/public/pages && git checkout master && cd ../../"
          end
      end
  end

@zx1986
Copy link

zx1986 commented Aug 17, 2016

I got NameError: uninitialized constant Capistrano::Git in Capistrano 3.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment