How to Configure Capistrano to Deploy from Local Git Repository?

Solution 1:

That's easy:

set :scm, :none
set :repository, "."
set :deploy_via, :copy

Simply run Capistrano from the root of your project.

Solution 2:

The deploy_via, :copy has been dropped in version 3.

https://github.com/capistrano/capistrano/issues/695

In most cases you should have your code in a online repository like github or bitbucket, and then you just have to set this line in your deploy.rb file:

set :repo_url, '[email protected]:my_account/my_project.git'

Though if you happen to have a repository on the remote server that you are deploying too, then you would change that line in your deploy.rb file to be this:

set :repo_url, 'file:///home/deploy/bare_repo/my_project.git'

Keep in mind that the three forward slashes are important since the file:// tells capistrano that you are looking for a file, and the preceding slash is needed to point to a root path which would be something like /home/deploy/bare_repo/my_project.git.