I am trying to setup my own production environment on digital ocean with ubuntu, rails and git.
I have followed this and this tutorial among others.
They all instruct to create the repository as bare, i.e.:
mkdir site.git && cd site.git
git init --bare
This operation must be run in a work tree
git --work-tree=/home/rails/myapp --git-dir=/var/repo/site.git checkout -f
If you are making a git push, you must do so from a normal git repo, meaning a local repo on your workstation (pushing indeed to a bare repo)
cd /path/to/my/local/repo git init . git add -A git commit -m "my first commit" git remote add origin /usr/bare/repo git push -u origin master
In your case, you cannot push directly from where the post-receive hook does a checkout, unless you mention in your git push command where the git repo is (bare or not)
cd /home/rails/myapp git --work-tree=/home/rails/myapp --git-dir=/var/repo/site.git push -u origin master
(and this assume
/var/repo/site.git does include a remote named origin)