I'm getting an error when trying to push to a remote Amazon EC2 (Ubuntu Linux) instance. I've given all related directories and files full permissions. I'm trying to use a post-receive hook to move the project to my production directory at /var/www/myapp
:
$ git push prod-server master
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 292 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: error: cannot run hooks/post-receive: No such file or directory
To prod-server:/home/ubuntu/myapp/myapp.git
8944048..a445d1d master -> master
My post-receive file (located in bare repository: /home/ubuntu/myapp/myapp.git/hooks/
):
#!/bin/bash
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "prod-server" == "$branch" -o "master" == "$branch" ]; then
git --work-tree=/var/www/myapp/ checkout -f $branch
echo 'Changes pushed to Amazon EC2 PROD-SERVER directory!'
fi
if [ "test" == "$branch" ]; then
git --work-tree=/var/www/myapp/test/ checkout -f $branch
echo 'Changes pushed to Amazon EC2 PROD-SERVER test directory!'
fi
done