Git post-receive hook acts differently to shell

自作多情 提交于 2019-12-20 03:08:01

问题


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:


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




回答2:


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.



来源:https://stackoverflow.com/questions/1898117/git-post-receive-hook-acts-differently-to-shell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!