在 post-receive hook 之后,裸 git 回购出现 500 内部服务器错误

500 Internal Server Error with bare git repo after post-receive hook

我认为这是我在这个专用服务器(使用 cpanel)上设置 Git 时遇到的最后一个问题。

我在我的 PC 上创建了一个裸仓库,并将其放在服务器上:/home/cpaneluser/git-repos/

已编辑 /home/cpaneluser/git-repos/myproject.git/hooks/post-receive,其内容为:

#!/bin/sh
GIT_WORK_TREE=/home/cpaneluser/public_html GIT_DIR=/home/cpaneluser/git-repos/myproject.git git checkout -f

我给了它 0764 权限,所以所有者可以执行它。它似乎执行得很好,因为它确实按预期将我的回购文件放入了我的 public_html 目录。

然后我在我的浏览器中导航到该域并收到一个内部服务器错误,它是通用的、无用的错误消息 The server encountered an internal error or misconfiguration and was unable to complete your request.

真正奇怪的是,如果我手动编辑位于 webroot 'public_html' 中的 'index.php' 文件,它似乎神奇地修复了所有问题。但是,进行此编辑会使获取回购与我的本地端不同步。

有谁知道为什么在 运行 'post-receive' 钩子执行 checkout -f 之后我会收到 Internet 服务器错误。我该如何解决这个问题?

谢谢。

添加 umask 0022 解决了我的权限问题。

#!/bin/sh
umask 0022
GIT_WORK_TREE=/home/cpaneluser/public_html GIT_DIR=/home/cpaneluser/git-repos/myproject.git git checkout -f