接收后挂钩失败“没有工作树就无法使用”
我使用此 Git 设置来管理网站: http://toroid.org/ams/git -网站-操作方法。
一切正常,直到我激活 post-receive 挂钩。在激活它之前,我可以毫无问题地推拉。但是,如果我激活钩子,它会说:
fatal: /usr/bin/git-checkout cannot be used without a working tree.
error: hooks/post-receive exited with error code 1
它仍然可以正确拉动,但不会按预期复制文件(到网络根目录)。但是 post-receive 钩子上写着:
#!/bin/sh
GIT_WORK_TREE=/home/domains/mydomain/html/ git checkout -f
那么为什么 git 会抱怨没有工作树呢?相同的语法适用于其他网站。
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 reads:
#!/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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能应该使用
git archive
而不是git checkout
来完成您在此处尝试执行的操作(使用挂钩将文件导出到 Web 服务器的文档根目录) 。这给您带来的优势之一是能够不从存储库导出某些文件(使用
.gitattributes
export-ignore 标志)。You should probably be using
git archive
instead ofgit checkout
for what it appears you're trying to do here (having a hook export the files to a web server's document root).One advantage this gives you is the ability to not export certain files from the repository (using the
.gitattributes
export-ignore flag).