简体   繁体   中英

Capistrano + Git : repository local to production server

I am trying to do 'deploy:cold' for my app. The git repo is local to my deployment server (ie I only have one server for everything and I don't host my code on github).

Here is the transcript (replaced my app name with "myapp" for privacy)

  * executing `deploy:cold'
  * executing `deploy:update'
 ** transaction: start
  * executing `deploy:update_code'
    executing locally: "git ls-remote /home/mrichman/git/myapp.git master"
fatal: '/home/mrichman/git/myapp.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
*** [deploy:update_code] rolling back
  * executing "rm -rf /var/www/myapp.com/releases/20100218203108; true"
    servers: ["myapp.com"]
Password:
    [myapp.com] executing command
    command finished
Command git ls-remote /home/mrichman/git/myapp.git master returned status code 32768

Here is my deploy.rb: http://pastie.org/831424

I have also tried

set :repository, "deploy@localhost:/home/mrichman/git/myapp.git"

but that gives me

ssh: connect to host localhost port 22: Connection refused

Any ideas are appreciated.

Just ran into the same problem. The key is to not use deploy_via copy but rather set :local_repository

This should be set to the URL you use to access the repository from your development computer/laptop.

So mine has

set :repository, "file:///srv/git/myapp.git"
set :local_repository, "nameOfHostFromSSHConfig:/srv/git/myapp.git"

Seems to have worked. Just remember to then remove the deploy_via copy line as well.

Log in as the user of the site you are deploying to and try this to see if your user has permission to access that directory:

ls -la /home/mrichman/git/myapp.git

If you get a Permission denied error then you'll have to make sure that you set permissions on the enclosing directories of the repository that allow the deployment script to access the files.

My problem was actually related to a known-hosts problem. All I had to do was make sure the remote git server was in my known hosts (trying to SSH into it for the first time will prompt you to add this yourself), and it worked like a charm.

If local_repository is set, then Capistrano uses the value of respository from the deployment server and the value of local_respository from the development server. Or something like that.

My configuration worked like so:

set :repository, "/home/#{user}/path/to/repo.git"
set :local_repository, "myserver.com:path/to/repo.git"

Make sure that you have written the correct git repo with caring case-sensitive writing! (I faced the same problem, it just solved)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM