R – Capistrano & Git: Needed a single revision

capistranodeploymentgitruby-on-rails

Capistrano and Git worked properly till I moved my site to another server. My first attempt to deploy went wrong because of an SSH-known-hosts related problem.

Even if I managed to solve this problem, another one raised and I can't deploy any more:

  * executing `deploy'
  * executing `deploy:update'
 ** transaction: start
  * executing `deploy:update_code'
    updating the cached checkout on all servers
    executing locally: "git ls-remote collimarco@mywebsite.com:/home/collimarco/git/foto-fiori.git master"
  * executing "if [ -d /home/collimarco/mywebsite.com/shared/cached-copy ]; then cd /home/collimarco/mywebsite.com/shared/cached-copy && git fetch  origin && git reset  --hard 7de27a6a1de7a94508f943596413e5e0f217f57e; else git clone  --depth 1 collimarco@mywebsite.com:/home/collimarco/git/foto-fiori.git /home/collimarco/mywebsite.com/shared/cached-copy && cd /home/collimarco/mywebsite.com/shared/cached-copy && git checkout  -b deploy 7de27a6a1de7a94508f943596413e5e0f217f57e; fi"
    servers: ["mywebsite.com"]
    [mywebsite.com] executing command
 ** [mywebsite.com :: out] * refusing to create funny ref 'remotes/origin/*' locally
 ** [mywebsite.com :: out] collimarco@mywebsite.com's password:
Password: 
 ** [mywebsite.com :: out]
 ** [mywebsite.com :: out] fatal: Needed a single revision
    command finished
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/collimarco/mywebsite.com/releases/20091027191027; true"
    servers: ["mywebsite.com"]
    [mywebsite.com] executing command
    command finished
failed: "sh -c \"if [ -d /home/collimarco/mywebsite.com/shared/cached-copy ]; then cd /home/collimarco/mywebsite.com/shared/cached-copy && git fetch  origin && git reset  --hard 7de27a6a1de7a94508f943596413e5e0f217f57e; else git clone  --depth 1 collimarco@mywebsite.com:/home/collimarco/git/foto-fiori.git /home/collimarco/mywebsite.com/shared/cached-copy && cd /home/collimarco/mywebsite.com/shared/cached-copy && git checkout  -b deploy 7de27a6a1de7a94508f943596413e5e0f217f57e; fi\"" on mywebsite.com

My git repository seems intact: why do I get "Needed a single revision"?

Any suggestion is greatly appreciated.
Thanks in advance!

UPDATE: someone suggested to remove the remote cache, how do I do that?

UPDATE: I have renamed shared/cached-copy into shared/cached-copy-old.
Then I have created a shared/cached-copy empty folder.
Now I get "Not a git repository":
http://pastie.org/672254.txt

Best Answer

Check your git versions on the client and the server; I bet you need to update one of them to 1.6.