开发者

post-receive hook fails "cannot be used without a working tree"

I've used this Git setup for managing a website: http://toroid.org/ams/git-website-howto.

Things work, until I active the post-receive hook. Before activating it, I can push and pull with no problem. However, if I activate the hook, it says:

fatal: /usr/bin/git-checkout cannot be used without a working tree.
error: hooks/post-receive exited with error code 1

It still pulls properly, but does not copy the files as it is supposed to (to the webroot). But the post-receive hook re开发者_Go百科ads:

#!/bin/sh
GIT_WORK_TREE=/home/domains/mydomain/html/ git checkout -f

So why is git complaining about not having a work tree? The same syntax worked for other websites.


You should probably be using git archive instead of git checkout for what it appears you're trying to do here (having a hook export the files to a web server's document root).

git archive HEAD | tar -xC /home/domains/mydomain/html/

One advantage this gives you is the ability to not export certain files from the repository (using the .gitattributes export-ignore flag).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜