0

我已使用此 Git 设置来管理网站:http ://toroid.org/ams/git-website-howto 。

一切正常,直到我激活了接收后挂钩。在激活它之前,我可以毫无问题地推拉。但是,如果我激活钩子,它会说:

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

它仍然可以正确拉动,但不会像预期的那样复制文件(到 webroot)。但是 post-receive 钩子上写着:

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

那么为什么 git 抱怨没有工作树呢?相同的语法适用于其他网站。

4

1 回答 1

2

您可能应该使用git archive而不是git checkout您在此处尝试执行的操作(使用挂钩将文件导出到 Web 服务器的文档根目录)。

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

这给您带来的一个好处是能够不从存储库中导出某些文件(使用.gitattributesexport-ignore 标志)。

于 2011-10-05T16:57:21.533 回答