views:

288

answers:

2

I'm trying to setup a git repo on my live server to automatically update a subdomain on receive. Using this guide http://toroid.org/ams/git-website-howto.

hooks/post-receive

#!/bin/sh
pwd
git checkout -f

config

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        worktree = /var/www/vhosts/domain.com/subdomains/staging/httpdocs
[receive]
        denycurrentbranch = ignore

If I run git checkout -f in /var/git/domain.com.git/ it works, the subdomain is updated. However, when I push I get the following output:

/var/git/domain.com.git
fatal: This operation must be run in a work tree

I'm not sure why this works in the shell, but not in the hook. Can anyone enlighten me?

+1  A: 

add cd /var/www/vhosts/domain.com/subdomains/staging/httpdocs to your post-recieve hook.

OneOfOne
This does not work in the hook or in shell.Because /var/www/vhosts/domain.com/subdomains/staging/httpdocs has not .git folder.It did however throw a permission denied error, because my ssh user has no permissions in that folder. Which I suspect is the cause of my problems.
Jake
A: 

The permissions on the worktree do not allow it to be read which causes the fatal: This operation must be run in a work tree error.

Jake