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?

Jake
  • 21
  • 3

2 Answers2

1

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

OneOfOne
  • 95,033
  • 20
  • 184
  • 185
  • 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 Dec 15 '09 at 02:08
0

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
  • 21
  • 3